-
Notifications
You must be signed in to change notification settings - Fork 0
/
karmaBaseConfig.js
124 lines (94 loc) · 3 KB
/
karmaBaseConfig.js
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */
const playwright = require("playwright");
// setting is to 0 will load browser binaries from node_modules folder
// inside playwright
process.env.PLAYWRIGHT_BROWSERS_PATH = 0;
process.env.FIREFOX_BIN = playwright.firefox.executablePath();
process.env.CHROME_BIN = playwright.chromium.executablePath();
process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath();
const localBrowserConfig = (webpackConfig, karmaConfig, packageConfig) => ({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "",
files: [{ pattern: "./test/*.js" }],
preprocessors: {
"./test/*.js": ["webpack"],
},
// frameworks to us
frameworks: ["mocha", "webpack"],
webpack: {
module: webpackConfig[2].module,
resolve: webpackConfig[2].resolve,
},
plugins: ["karma-mocha-reporter", "karma-webkit-launcher", "karma-chrome-launcher", "karma-firefox-launcher", "karma-mocha", "karma-webpack"],
client: {
mocha: {
timeout: 0,
},
args: packageConfig.args,
},
singleRun: true,
reporters: ["mocha"],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
logLevel: karmaConfig.LOG_INFO,
// Set the browser to run
// can be overrided using --browsers args while running test command
// but due to limitation in lerna package scoping cannot be done while
// passing other args.
// Args are passed in CI file as scoping is not required in CI,
// for local testing , edit here directly.
browsers: ["ChromeHeadless"],
});
// eslint-disable-next-line no-console
const browserStackConfig = (webpackConfig, karmaConfig, packageConfig) => ({
browserStack: {
username: process.env.BROWSER_STACK_USERNAME,
accessKey: process.env.BROWSER_STACK_KEY,
project: packageConfig.name,
},
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "",
files: [{ pattern: "./test/*.js" }],
preprocessors: {
"./test/*.js": ["webpack"],
},
// frameworks to us
frameworks: ["mocha", "webpack"],
webpack: {
module: webpackConfig[2].module,
resolve: webpackConfig[2].resolve,
},
plugins: ["karma-webpack", "karma-mocha", "karma-browserstack-launcher"],
client: {
mocha: {
timeout: 0,
},
args: packageConfig.args,
},
reporters: ["progress", "BrowserStack"],
// web server port
port: 9876,
concurrency: 1,
singleRun: true,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
logLevel: karmaConfig.LOG_INFO,
// define browsers
customLaunchers: {
bs_firefox_windows: {
base: "BrowserStack",
browser: "Chrome",
browser_version: "90.0",
os: "Windows",
os_version: "10",
video: false,
},
},
browsers: ["bs_firefox_windows"],
});
module.exports = { localBrowserConfig, browserStackConfig };