Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / crypto / test / karma.conf.js
blobf8f0dff4433f0c1aa585af5fe283669fe1eca1e1
1 const path = require('path');
2 const os = require('os');
3 const { firefox, chromium, webkit } = require('playwright');
4 const karmaJasmine = require('karma-jasmine');
5 const karmaWebpack = require('karma-webpack');
6 const karmaChromeLauncher = require('karma-chrome-launcher');
7 const karmaFirefoxLauncher = require('karma-firefox-launcher');
8 const karmaWebkitLauncher = require('karma-webkit-launcher');
9 const karmaSpecReporter = require('karma-spec-reporter');
10 process.env.CHROME_BIN = chromium.executablePath();
11 process.env.FIREFOX_BIN = firefox.executablePath();
12 process.env.WEBKIT_HEADLESS_BIN = webkit.executablePath();
14 /**
15 * Karma does not automatically serve the bundled webworker asset generated by webpack,
16 * so we need to manually reference and expose the webpack temporary output dir.
17 * See: https://github.com/ryanclark/karma-webpack/issues/498#issuecomment-790040818
19 const karmaWebpackOutputPath = path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000);
21 module.exports = function (config) {
22 config.set({
23 // base path that will be used to resolve all patterns (eg. files, exclude)
24 basePath: '..',
26 // frameworks to use
27 // available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
28 frameworks: ['jasmine', 'webpack'],
30 plugins: [
31 karmaJasmine,
32 karmaWebpack,
33 karmaChromeLauncher,
34 process.env.CI ? undefined : karmaFirefoxLauncher,
35 karmaWebkitLauncher,
36 karmaSpecReporter,
37 ].filter(Boolean),
39 // list of files / patterns to load in the browser
40 files: [
41 { pattern: 'test/**/!(karma.conf).*', watched: false },
43 pattern: `${karmaWebpackOutputPath}/**/*`,
44 watched: false,
45 included: false,
46 served: true,
50 // list of files / patterns to exclude
51 exclude: [],
53 // preprocess matching files before serving them to the browser
54 // available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor
55 preprocessors: {
56 'test/**/*.*': 'webpack',
59 webpack: {
60 output: {
61 path: karmaWebpackOutputPath,
64 resolve: {
65 fallback: {
66 stream: false,
67 buffer: false,
69 extensions: ['', '.js', '.ts'],
71 module: {
72 rules: [
74 test: /\.ts?$/,
75 use: [
77 loader: 'ts-loader',
78 options: {
79 compilerOptions: { noEmit: false },
80 allowTsInNodeModules: true,
84 exclude: /node_modules\/(?!.*(pmcrypto))/,
90 // available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter
91 reporters: ['spec'],
93 // web server port
94 port: 9875,
96 // enable / disable colors in the output (reporters and logs)
97 colors: true,
99 // level of logging
100 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
101 logLevel: config.LOG_INFO,
103 // enable / disable watching file and executing tests whenever any file changes
104 autoWatch: false,
106 customLaunchers: {
107 ChromeHeadlessCI: {
108 base: 'ChromeHeadless',
109 flags: ['--no-sandbox'],
112 browsers: ['ChromeHeadlessCI', process.env.CI ? undefined : 'FirefoxHeadless', 'WebkitHeadless'].filter(
113 Boolean
116 // Continuous Integration mode
117 // if true, Karma captures browsers, runs the tests and exits
118 singleRun: true,
120 // Concurrency level
121 // how many browser instances should be started simultaneously
122 concurrency: Infinity,
124 client: {
125 jasmine: {
126 // Run tests in serial so that endpoint release don't interfere
127 random: false,
128 // timeout for tests, default is 2 seconds. Some streaming tests can take longer.
129 timeoutInterval: 30000,