Skip to content

Commit

Permalink
test: fix issue with karma failing to start Firefox locally on MacOS
Browse files Browse the repository at this point in the history
This issue has been raised on karma-firefox-launcher but it's yet
to be released
karma-runner/karma-firefox-launcher#328
  • Loading branch information
meel-io committed Feb 12, 2024
1 parent 925da68 commit d712db9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .toolkitrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ plugins:

hooks:
test:local:
- Karma
- KarmaLocal
test:ci:
- Karma
- KarmaCI

options:
"@dotcom-tool-kit/circleci":
Expand Down
19 changes: 17 additions & 2 deletions toolkit/karma/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { spawn } = require('child_process');
const { hookFork, waitOnExit } = require('@dotcom-tool-kit/logger');
const karmaCLIPath = require.resolve('karma/bin/karma')

class Karma extends Task {
class KarmaCI extends Task {
async run() {
const args = ['start', 'test/karma.conf.js']
this.logger.info(`running karma ${args.join(' ')}`)
Expand All @@ -13,5 +13,20 @@ class Karma extends Task {
}
}

exports.tasks = [ Karma ];
class KarmaLocal extends KarmaCI {
async run() {
// karma-firefox-launcher no longer works for Firefox versions > 121 on MacOS
// This is a temporary fix while they release a permanent fix for the issue
// See https://github.com/karma-runner/karma-firefox-launcher/issues/328
if (process.platform !== 'darwin') {
return super.run()
}

process.env.FIREFOX_BIN = '/Applications/Firefox.app/Contents/MacOS/firefox'

super.run()
}
}

exports.tasks = [ KarmaCI, KarmaLocal ];

0 comments on commit d712db9

Please sign in to comment.