forked from sweetalert2/sweetalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
133 lines (115 loc) · 2.64 KB
/
karma.conf.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
125
126
127
128
129
130
131
132
133
const noLaunch = process.argv.includes('--no-launch')
const testMinified = process.argv.includes('--minified')
const isSauce = process.argv.includes('--sauce')
const isNetlify = process.argv.includes('--netlify')
if (isNetlify) {
process.env.CHROME_BIN = require('puppeteer').executablePath()
}
const webpackConfig = {
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|dist)/,
use: {
loader: 'babel-loader',
options: {/* babel options */}
}
}
]
}
}
const karmaPlugins = [
'karma-webpack',
'karma-qunit',
'karma-spec-reporter',
'karma-sourcemap-loader',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-ie-launcher',
'karma-sauce-launcher'
]
const preprocessors = {
'test/qunit/**/*.js': [
'webpack',
'sourcemap'
],
}
const sauceLabsLaunchers = {
safari: {
base: 'SauceLabs',
browserName: 'Safari',
version: 'latest',
platformName: 'macOS 10.15'
},
edge: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
browserVersion: '18.17763',
platformName: 'Windows 10',
},
ie: {
base: 'SauceLabs',
browserName: 'internet explorer',
browserVersion: 'latest',
platformName: 'Windows 7'
},
}
function checkSauceCredentials () {
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
console.error('SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables must be set')
process.exit(1)
}
}
function getFiles () {
let files
if (testMinified) {
files = [
'dist/sweetalert2.all.min.js'
]
} else {
files = [
'dist/sweetalert2.css',
'dist/sweetalert2.js'
]
}
return files.concat([
'node_modules/promise-polyfill/dist/polyfill.min.js',
'test/qunit/**/*.js'
])
}
function getBrowsers () {
if (noLaunch) {
return []
}
let browsers = ['ChromeHeadless']
// Cron on GitHub Actions or check:qunit --sauce
if (isSauce) {
checkSauceCredentials()
browsers = Object.keys(sauceLabsLaunchers)
// GitHub Actions
} else if (process.env.GITHUB_ACTION) {
browsers = ['ChromeHeadless', 'FirefoxHeadless']
}
return browsers
}
module.exports = function (config) {
config.set({
port: 3000,
plugins: karmaPlugins,
frameworks: ['qunit'],
qunit: { reorder: false },
customLaunchers: sauceLabsLaunchers,
files: getFiles(),
browsers: getBrowsers(),
reporters: ['spec', 'saucelabs'],
preprocessors,
webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only'
},
captureTimeout: 360000,
browserNoActivityTimeout: 360000
})
}