Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / shared / test / karma.conf.js
blob396cac762c9c007382336a1aeeb63dbc65d23e82
1 const karmaJasmine = require('karma-jasmine');
2 const karmaWebpack = require('karma-webpack');
3 const karmaSpecReporter = require('karma-spec-reporter');
4 const karmaChromeLauncher = require('karma-chrome-launcher');
5 const karmaJunitReporter = require('karma-junit-reporter');
6 const { chromium } = require('playwright');
7 const { existsSync } = require('node:fs');
8 process.env.CHROME_BIN = chromium.executablePath();
10 if (!existsSync(process.env.CHROME_BIN)) {
11     throw new Error('Chromium executable not found. Run `npx playwright install chromium`');
14 module.exports = (config) => {
15     config.set({
16         basePath: '..',
17         frameworks: ['jasmine', 'webpack'],
18         plugins: [karmaJasmine, karmaWebpack, karmaChromeLauncher, karmaSpecReporter, karmaJunitReporter],
19         files: ['test/index.spec.js'],
20         preprocessors: {
21             'test/index.spec.js': ['webpack'],
22         },
23         webpack: {
24             mode: 'development',
25             resolve: {
26                 extensions: ['.js', '.ts', '.tsx'],
27                 fallback: {
28                     crypto: false,
29                     buffer: false,
30                     stream: false,
31                 },
32             },
33             module: {
34                 rules: [
35                     {
36                         test: /\.tsx?$/,
37                         use: [
38                             {
39                                 loader: 'ts-loader',
40                                 options: { transpileOnly: true },
41                             },
42                         ],
43                         exclude: /node_modules\/(?!.*(bip39|pmcrypto))/,
44                     },
45                 ],
46             },
47             devtool: 'inline-source-map',
48         },
49         mime: {
50             'text/x-typescript': ['ts', 'tsx'],
51         },
52         reporters: ['spec', 'junit'],
53         junitReporter: {
54             outputDir: '', // results will be saved as $outputDir/$browserName.xml
55             outputFile: 'test-report.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
56             suite: '', // suite will become the package name attribute in xml testsuite element
57             useBrowserName: false, // add browser name to report and classes names
58         },
59         specReporter: {
60             suppressSkipped: true, // do not print information about skipped tests
61         },
62         port: 9874,
63         colors: true,
64         logLevel: config.LOG_INFO,
65         autoWatch: false,
66         customLaunchers: {
67             ChromeHeadlessCI: {
68                 base: 'ChromeHeadless',
69                 flags: ['--no-sandbox'],
70             },
71         },
72         browsers: ['ChromeHeadlessCI'],
73         singleRun: true,
74         concurrency: Infinity,
75         client: {
76             jasmine: {
77                 timeoutInterval: 10000,
78             },
79         },
80     });