Skip to content

Commit

Permalink
tests: On Linux, let npm test default to Chromium instead of Chrome
Browse files Browse the repository at this point in the history
By default `npm test` will run concurrenty in Firefox and one of
Chromium/Chrome. Chrome for macOS and Win, and Chromium on Linux
unless CHROME_BIN is configured by the user's env variables, in
which case they're likely to prefer that and/or not have Chromium
installed.

Also provide `npm run test-unit-…` commands which run unit tests
in a single specific browser only (overrides the conf array).

Follows-up #672.
  • Loading branch information
Krinkle committed Jan 27, 2021
1 parent 0ea8a91 commit 55186c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"scripts": {
"test": "npm run test-unit-local",
"test-unit-local": "karma start tests/karma.conf.local.js",
"test-unit-firefox": "karma start tests/karma.conf.local.js --browsers FirefoxHeadless",
"test-unit-chromium": "karma start tests/karma.conf.local.js --browsers ChromiumHeadless",
"test-unit-chrome": "karma start tests/karma.conf.local.js --browsers ChromeHeadless",
"test-unit-saucelabs": "karma start tests/karma.conf.saucelabs.js"
},
"engines": {
Expand Down
8 changes: 7 additions & 1 deletion tests/karma.conf.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ module.exports = function (config) {
// https://karma-runner.github.io/5.2/config/browsers.html
browsers: [
'FirefoxHeadless',
'ChromeHeadless'
// During local development, consider Chrome and Chromium to be similar enough
// and pick whichever the developer is most likely to have.
// In general, Linux distros provide and update Chromium only,
// whereas Windows and macOS users tend to have auto-updating Google Chrome.
//
// See package.json for commands to run tests in a single browser only.
process.platform === 'linux' ? 'ChromiumHeadless' : 'ChromeHeadless'
],
frameworks: ['qunit'],
client: {
Expand Down

0 comments on commit 55186c8

Please sign in to comment.