2018-04-26 05:20:55 +03:00
|
|
|
/**
|
|
|
|
@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) {
|
2019-08-22 03:52:17 +03:00
|
|
|
const packages = config.packages ? config.packages.split(',') : [];
|
|
|
|
const fileEntries = [];
|
2019-11-23 05:26:54 +03:00
|
|
|
const defaultFileEntry = [{
|
2020-08-18 03:59:35 +03:00
|
|
|
pattern: 'test/lib/packages/*/test/*.test.js',
|
2019-11-23 05:26:54 +03:00
|
|
|
watched: true,
|
|
|
|
type: 'module'
|
|
|
|
}];
|
2019-08-22 03:52:17 +03:00
|
|
|
|
|
|
|
for (const package of packages) {
|
2019-09-25 00:14:52 +03:00
|
|
|
const withoutMwcPrefix = package.replace(/^mwc-/, '');
|
|
|
|
const fileEntry = {
|
2019-11-23 05:26:54 +03:00
|
|
|
pattern:
|
2020-08-18 03:59:35 +03:00
|
|
|
`test/lib/packages/${withoutMwcPrefix}/test/${package}.test.js`,
|
2019-09-25 00:14:52 +03:00
|
|
|
watched: true,
|
|
|
|
type: 'module',
|
|
|
|
};
|
2019-08-22 03:52:17 +03:00
|
|
|
fileEntries.push(fileEntry);
|
|
|
|
}
|
|
|
|
|
2019-08-23 07:28:00 +03:00
|
|
|
const testFileEntries = fileEntries.length ? fileEntries : defaultFileEntry;
|
2019-08-22 03:52:17 +03:00
|
|
|
|
2018-04-26 05:20:55 +03:00
|
|
|
config.set({
|
|
|
|
basePath: '',
|
2019-12-02 09:15:58 +03:00
|
|
|
plugins: [
|
|
|
|
require.resolve('@open-wc/karma-esm'),
|
|
|
|
'karma-*',
|
|
|
|
],
|
2021-05-25 22:08:30 +03:00
|
|
|
frameworks: ['esm', 'jasmine'],
|
2018-04-26 05:20:55 +03:00
|
|
|
files: [
|
2019-11-23 05:26:54 +03:00
|
|
|
{
|
|
|
|
pattern:
|
|
|
|
'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js',
|
|
|
|
watched: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pattern:
|
|
|
|
'node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js',
|
|
|
|
watched: false
|
|
|
|
},
|
2019-08-22 03:52:17 +03:00
|
|
|
...testFileEntries
|
2018-04-26 05:20:55 +03:00
|
|
|
],
|
2019-01-31 04:53:53 +03:00
|
|
|
|
2019-08-23 07:28:00 +03:00
|
|
|
browserDisconnectTimeout: 300000,
|
|
|
|
browserNoActivityTimeout: 360000,
|
|
|
|
captureTimeout: 420000,
|
2019-11-23 05:26:54 +03:00
|
|
|
concurrency: 10,
|
2018-04-26 05:20:55 +03:00
|
|
|
|
2019-12-02 09:15:58 +03:00
|
|
|
esm: {
|
|
|
|
nodeResolve: true,
|
|
|
|
compatibility: 'auto',
|
|
|
|
preserveSymlinks: true,
|
|
|
|
},
|
|
|
|
|
2019-08-24 03:05:22 +03:00
|
|
|
reporters: ['mocha'],
|
2019-11-23 05:26:54 +03:00
|
|
|
|
|
|
|
// Note setting --browsers on the command-line always overrides this list.
|
|
|
|
browsers: [
|
|
|
|
'ChromeHeadless',
|
|
|
|
'FirefoxHeadless',
|
|
|
|
],
|
2018-04-26 05:20:55 +03:00
|
|
|
});
|
|
|
|
|
2019-11-23 05:26:54 +03:00
|
|
|
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 = {
|
2020-03-03 04:03:14 +03:00
|
|
|
'sl-edge': {
|
2019-11-23 05:26:54 +03:00
|
|
|
base: 'SauceLabs',
|
|
|
|
browserName: 'microsoftedge',
|
2020-03-03 04:03:14 +03:00
|
|
|
version: 'latest',
|
2019-11-23 05:26:54 +03:00
|
|
|
platform: 'Windows 10',
|
|
|
|
},
|
2020-03-03 04:03:14 +03:00
|
|
|
'sl-ie': {
|
2019-11-23 05:26:54 +03:00
|
|
|
base: 'SauceLabs',
|
2020-03-03 04:03:14 +03:00
|
|
|
browserName: 'internet explorer',
|
|
|
|
version: '11',
|
|
|
|
platform: 'Windows 8.1',
|
2019-11-23 05:26:54 +03:00
|
|
|
},
|
2021-01-12 01:47:11 +03:00
|
|
|
'sl-safari-14': {
|
2019-11-23 05:26:54 +03:00
|
|
|
base: 'SauceLabs',
|
|
|
|
browserName: 'safari',
|
2021-01-12 01:47:11 +03:00
|
|
|
version: '14',
|
|
|
|
platform: 'macOS 11.00',
|
2019-11-23 05:26:54 +03:00
|
|
|
},
|
2021-01-12 01:47:11 +03:00
|
|
|
'sl-safari-13': {
|
2019-11-23 05:26:54 +03:00
|
|
|
base: 'SauceLabs',
|
|
|
|
browserName: 'safari',
|
2021-01-12 01:47:11 +03:00
|
|
|
version: '13',
|
2021-01-12 02:31:47 +03:00
|
|
|
platform: 'macOS 10.15',
|
2019-11-23 05:26:54 +03:00
|
|
|
},
|
2019-12-02 09:15:58 +03:00
|
|
|
// 'sl-chrome-41': {
|
|
|
|
// base: 'SauceLabs',
|
|
|
|
// browserName: 'chrome',
|
|
|
|
// version: '41',
|
|
|
|
// platform: 'Linux'
|
|
|
|
// },
|
2019-11-23 05:26:54 +03:00
|
|
|
};
|
|
|
|
|
2018-04-26 05:20:55 +03:00
|
|
|
config.set({
|
|
|
|
sauceLabs: {
|
2019-11-23 05:26:54 +03:00
|
|
|
idleTimeout: 600,
|
|
|
|
testName: 'MWC Unit Tests',
|
|
|
|
build: process.env.SAUCE_BUILD_ID,
|
|
|
|
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
|
2018-04-26 05:20:55 +03:00
|
|
|
},
|
|
|
|
// Attempt to de-flake Sauce Labs tests on TravisCI.
|
|
|
|
transports: ['polling'],
|
2019-11-23 05:26:54 +03:00
|
|
|
browserDisconnectTolerance: 1,
|
2019-08-24 03:15:13 +03:00
|
|
|
reporters: ['saucelabs', 'mocha'],
|
2019-11-23 05:26:54 +03:00
|
|
|
|
|
|
|
// TODO(aomarks) Update the browser versions here.
|
|
|
|
customLaunchers: SAUCE_LAUNCHERS,
|
|
|
|
browsers: [...config.browsers, ...Object.keys(SAUCE_LAUNCHERS)],
|
2018-04-26 05:20:55 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|