From 10c432b2d33d396f831a46dfd461236e41102f56 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Thu, 4 Jul 2024 10:44:22 +0200 Subject: [PATCH] test: configure Firefox (headless) Using a local profile directory, this works on modern Linux, too: https://github.com/karma-runner/karma-firefox-launcher/issues/183#issuecomment-1283875784 --- .gitignore | 1 + karma.conf.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index e20452e38..f5532e2c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules/ dist/ +tmp/ coverage/ lib/**/*.d.ts .idea/ diff --git a/karma.conf.js b/karma.conf.js index cd579f2c3..b2eade39c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,6 +2,8 @@ var path = require('path'); +var fs = require('fs'); + var coverage = process.env.COVERAGE; // configures browsers to run test against @@ -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'; @@ -35,6 +43,14 @@ module.exports = function(karma) { reporters: [ 'progress' ].concat(coverage ? 'coverage' : []), + customLaunchers: { + 'FirefoxHeadless': { + base: 'Firefox', + flags: [ '-headless' ], + profile: firefoxProfile + } + }, + browsers, browserNoActivityTimeout: 30000,