generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 105
/
karma.conf.cjs
89 lines (70 loc) · 2.78 KB
/
karma.conf.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Karma is what we're using to run our tests in browser environments
// Karma does not support .mjs
// playwright acts as a safari executable on windows and mac
const playwright = require('playwright');
const esbuildBrowserConfig = require('./build/esbuild-browser-config.cjs');
// use playwright chrome exec path as run target for chromium tests
process.env.CHROME_BIN = playwright.chromium.executablePath();
// use playwright webkit exec path as run target for safari tests
process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath();
// use playwright firefox exec path as run target for firefox tests
process.env.FIREFOX_BIN = playwright.firefox.executablePath();
/** @typedef {import('karma').Config} KarmaConfig */
/**
*
* @param {KarmaConfig} config
*/
module.exports = function configure(config) {
config.set({
plugins: [
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-webkit-launcher'),
require('karma-esbuild'),
require('karma-mocha'),
require('karma-mocha-reporter')
],
// frameworks to use
// available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
frameworks: ['mocha'],
client: {
// Increase Mocha's default timeout of 2 seconds to prevent timeouts during GitHub CI runs.
mocha: {
timeout: 10000 // 10 seconds
}
},
// list of files / patterns to load in the browser
files: [
{ pattern: 'tests/**/*.spec.ts', watched: false }
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor
preprocessors: {
'tests/**/*.ts': ['esbuild']
},
esbuild: esbuildBrowserConfig,
// list of files / patterns to exclude
exclude: [],
// test results reporter to use
// available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter
reporters: ['mocha'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN ||
// config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
concurrency: 1,
// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: ['ChromeHeadless', 'FirefoxHeadless', 'WebkitHeadless'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Increase browser timeouts to avoid DISCONNECTED messages during GitHub CI runs.
browserDisconnectTimeout : 10000, // default 2000
browserDisconnectTolerance : 1, // default 0
});
};