From 4e02e4439d72a4de7aa4beb0fbdb13c7e0514d9b Mon Sep 17 00:00:00 2001 From: heyarne Date: Sat, 21 Dec 2019 11:43:38 +0100 Subject: [PATCH] Remove chromium dependency for tests (#73) --- README.md | 6 +++--- karma.conf.js | 25 +++++++++++++++++++------ package-lock.json | 17 +++++++++++++++++ package.json | 1 + 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 034dfb4..dd2f3a2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repository contains an alternative web frontend for [airsonic](https://github.com/airsonic/airsonic). The goal is to eventually be able to fully replace the current web interface. -## Implemented so far +## Implemented So Far * Login with persisting credentials * Browse your library by newest / most recently played / starred @@ -39,7 +39,7 @@ $ npm run dev All other build tasks are defined in the `package.json` (more below). -### Editor integration +### Editor Integration Integrating shadow-cljs with your editor helps tremendously with development. After having run `npm run dev` as described above you can connect to the REPL and get features like in-editor code execution and code completion / documentation lookup. For further information see [this part of the shadow-cljs user guide](https://shadow-cljs.github.io/docs/UsersGuide.html#_editor_integration). Recommended editors and plugins are Calva for VSCode and CIDER for Emacs (comes with Spacemacs). Make sure to open `localhost:8080` in the browser after starting the `dev:cljs` task to execute ClojureScript code in a live REPL. @@ -53,7 +53,7 @@ It provides you with tools to inspect the state of the application, undo and rep ## Tests -This project uses [karma](https://karma-runner.github.io/) for tests. Make sure to have Google Chrome installed, otherwise the watcher will time out. +This project uses [karma](https://karma-runner.github.io/) for tests. There is a check inside `karma.conf.js` to see whether Firefox is installed (via `which firefox` which probably breaks on Windows 🤷); if that command doesn't fail it will be used as the test runner. Otherwise Chrome will be used. If you have Chromium installed, make sure to set the `CHROME_BIN` environment variable to point to Chromium. ``` # run tests once diff --git a/karma.conf.js b/karma.conf.js index e7678cc..126c682 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,23 @@ +const { execSync } = require('child_process') + module.exports = function (config) { + + let browsers = null; + if (process.env.TRAVIS || process.env.CI) { + // custom config for continuous integration + browsers = ['ChromeHeadlessCI'] + } else { + try { + // if Firefox is installed, use that as the test runner + execSync('which firefox') + browsers = ['FirefoxHeadless'] + } catch (_) { + browsers = ['ChromeHeadless'] + } + } + const configuration = { - browsers: ['ChromeHeadless'], + browsers: browsers, // The tests are sometimes run before the tests were completely written // to disc; this is a known problem unfortunately. This is a hack to at // least keep the browsers connected so the tests are compiled and run @@ -15,6 +32,7 @@ module.exports = function (config) { plugins: [ 'karma-cljs-test', 'karma-chrome-launcher', + 'karma-firefox-launcher', 'karma-notify-reporter' // reporters are set in package.json ], colors: true, @@ -31,10 +49,5 @@ module.exports = function (config) { } } - if (process.env.TRAVIS || process.env.CI) { - configuration.browsers = ['ChromeHeadlessCI'] - } - - config.set(configuration) } diff --git a/package-lock.json b/package-lock.json index 25c0569..e829fdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4004,6 +4004,23 @@ "integrity": "sha1-y4YF7w4R+ab20o9Wul298m84mSM=", "dev": true }, + "karma-firefox-launcher": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.2.0.tgz", + "integrity": "sha512-j9Zp8M8+VLq1nI/5xZGfzeaEPtGQ/vk3G+Y8vpmFWLvKLNZ2TDjD6cu2dUu7lDbu1HXNgatsAX4jgCZTkR9qhQ==", + "dev": true, + "requires": { + "is-wsl": "^2.1.0" + }, + "dependencies": { + "is-wsl": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.1.1.tgz", + "integrity": "sha512-umZHcSrwlDHo2TGMXv0DZ8dIUGunZ2Iv68YZnrmCiBPkZ4aaOhtv7pXJKeki9k3qJ3RJr0cDyitcl5wEH3AYog==", + "dev": true + } + } + }, "karma-notify-reporter": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/karma-notify-reporter/-/karma-notify-reporter-1.1.0.tgz", diff --git a/package.json b/package.json index 4e7c292..3dfdbf5 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "karma": "^4.0.1", "karma-chrome-launcher": "^3.0.0", "karma-cljs-test": "^0.1.0", + "karma-firefox-launcher": "^1.2.0", "karma-notify-reporter": "^1.1.0", "node-sass": "^4.11.0", "npm-run-all": "^4.1.5",