forked from Polymer/web-component-tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
105 lines (92 loc) · 2.99 KB
/
config.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
/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import * as util from './util.js';
import ChildRunner from './childrunner.js';
/**
* The global configuration state for WCT's browser client.
*/
export var _config = {
/**
* `.js` scripts to be loaded (synchronously) before WCT starts in earnest.
*
* Paths are relative to `scriptPrefix`.
*/
environmentScripts: [
// https://github.com/PolymerLabs/stacky/issues/2
'stacky/lib/parsing.js',
'stacky/lib/formatting.js',
'stacky/lib/normalization.js',
'async/lib/async.js',
'lodash/lodash.js',
'mocha/mocha.js',
'chai/chai.js',
'sinonjs/sinon.js',
'sinon-chai/lib/sinon-chai.js',
'accessibility-developer-tools/dist/js/axs_testing.js'
],
/** Absolute root for client scripts. Detected in `setup()` if not set. */
root: null,
/** By default, we wait for any web component frameworks to load. */
waitForFrameworks: true,
/** How many `.html` suites that can be concurrently loaded & run. */
numConcurrentSuites: 1,
/** Whether `console.error` should be treated as a test failure. */
trackConsoleError: true,
/** Configuration passed to mocha.setup. */
mochaOptions: {
timeout: 10 * 1000
},
/** Whether WCT should emit (extremely verbose) debugging log messages. */
verbose: false,
};
/**
* Merges initial `options` into WCT's global configuration.
*
* @param {Object} options The options to merge. See `browser/config.js` for a
* reference.
*/
export function setup(options) {
var childRunner = ChildRunner.current();
if (childRunner) {
_deepMerge(_config, childRunner.parentScope.WCT._config);
// But do not force the mocha UI
delete _config.mochaOptions.ui;
}
if (options && typeof options === 'object') {
_deepMerge(_config, options);
}
if (!_config.root) {
// Sibling dependencies.
var root = util.scriptPrefix('browser.js');
_config.root = util.basePath(root.substr(0, root.length - 1));
if (!_config.root) {
throw new Error('Unable to detect root URL for WCT sources. Please set WCT.root before including browser.js');
}
}
}
/**
* Retrieves a configuration value.
*
* @param {string} key
* @return {*}
*/
export function get(key) {
return _config[key];
}
// Internal
function _deepMerge(target, source) {
Object.keys(source).forEach(function(key) {
if (target[key] !== null && typeof target[key] === 'object' && !Array.isArray(target[key])) {
_deepMerge(target[key], source[key]);
} else {
target[key] = source[key];
}
});
}