Skip to content

Commit

Permalink
test: configure Firefox (headless)
Browse files Browse the repository at this point in the history
Using a local profile directory, this works on modern Linux, too:

karma-runner/karma-firefox-launcher#183 (comment)
  • Loading branch information
nikku committed Jul 4, 2024
1 parent e32148a commit a4ccc1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
dist/
tmp/
coverage/
lib/**/*.d.ts
.idea/
Expand Down
16 changes: 16 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

var path = require('path');

var fs = require('fs');

var coverage = process.env.COVERAGE;

// configures browsers to run test against
Expand All @@ -11,6 +13,12 @@ var browsers = (process.env.TEST_BROWSERS || 'ChromeHeadless').split(',');
// use puppeteer provided Chrome for testing
process.env.CHROME_BIN = require('puppeteer').executablePath();

var tmpDir = path.join(__dirname, 'tmp');

fs.mkdirSync(tmpDir, { recursive: true });

var firefoxProfile = fs.mkdtempSync(path.join(tmpDir, 'firefox-profile'));

var absoluteBasePath = path.resolve(__dirname);

var suite = coverage ? 'test/coverageBundle.js' : 'test/testBundle.js';
Expand All @@ -35,6 +43,14 @@ module.exports = function(karma) {

reporters: [ 'progress' ].concat(coverage ? 'coverage' : []),

customLaunchers: {
'FirefoxHeadless': {
base: 'Firefox',
flags: [ '-headless' ],
profile: firefoxProfile
}
},

browsers,

browserNoActivityTimeout: 30000,
Expand Down

0 comments on commit a4ccc1f

Please sign in to comment.