forked from material-components/material-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
150 lines (134 loc) · 3.86 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
@license
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
module.exports = function(config) {
const packages = config.packages ? config.packages.split(',') : [];
const fileEntries = [];
const defaultFileEntry = [{
pattern: 'test/lib/packages/*/src/test/*.test.js',
watched: true,
type: 'module'
}];
for (const package of packages) {
const withoutMwcPrefix = package.replace(/^mwc-/, '');
const fileEntry = {
pattern:
`test/lib/packages/${withoutMwcPrefix}/src/test/${package}.test.js`,
watched: true,
type: 'module',
};
fileEntries.push(fileEntry);
}
const testFileEntries = fileEntries.length ? fileEntries : defaultFileEntry;
config.set({
basePath: '',
plugins: [
require.resolve('@open-wc/karma-esm'),
'karma-*',
],
frameworks: ['esm', 'mocha', 'chai'],
files: [
{
pattern:
'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js',
watched: false
},
{
pattern:
'node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js',
watched: false
},
...testFileEntries
],
browserDisconnectTimeout: 300000,
browserNoActivityTimeout: 360000,
captureTimeout: 420000,
concurrency: 10,
esm: {
nodeResolve: true,
compatibility: 'auto',
preserveSymlinks: true,
},
client: {
mocha: {
reporter: 'html',
ui: 'tdd',
},
},
reporters: ['mocha'],
// Note setting --browsers on the command-line always overrides this list.
browsers: [
'ChromeHeadless',
'FirefoxHeadless',
],
});
if (process.env.USE_SAUCE) {
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
throw new Error(
'SAUCE_USERNAME and SAUCE_ACCESS_KEY must be set with USE_SAUCE')
}
const SAUCE_LAUNCHERS = {
'sl-edge': {
base: 'SauceLabs',
browserName: 'microsoftedge',
version: 'latest',
platform: 'Windows 10',
},
'sl-ie': {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11',
platform: 'Windows 8.1',
},
'sl-safari-11': {
base: 'SauceLabs',
browserName: 'safari',
version: '11',
platform: 'macOS 10.13',
},
'sl-safari-10': {
base: 'SauceLabs',
browserName: 'safari',
version: '10',
platform: 'OS X 10.12',
},
// 'sl-safari-9': {
// base: 'SauceLabs',
// browserName: 'safari',
// version: '9',
// platform: 'OS X 10.11',
// },
// 'sl-chrome-41': {
// base: 'SauceLabs',
// browserName: 'chrome',
// version: '41',
// platform: 'Linux'
// },
};
config.set({
sauceLabs: {
idleTimeout: 600,
testName: 'MWC Unit Tests',
build: process.env.SAUCE_BUILD_ID,
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
},
// Attempt to de-flake Sauce Labs tests on TravisCI.
transports: ['polling'],
browserDisconnectTolerance: 1,
reporters: ['saucelabs', 'mocha'],
// TODO(aomarks) Update the browser versions here.
customLaunchers: SAUCE_LAUNCHERS,
browsers: [...config.browsers, ...Object.keys(SAUCE_LAUNCHERS)],
});
}
};