forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbazel-karma-local-config.js
46 lines (39 loc) · 1.72 KB
/
bazel-karma-local-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
/**
* Karma configuration that is used by Bazel karma_web_test targets which do not
* want to launch any browser and just enable manual browser debugging.
*/
module.exports = config => {
const overwrites = {};
// By default "@bazel/concatjs" configures Chrome as browser. Since we don't want
// to launch any browser at all, we overwrite the "browsers" option. Since the
// default config tries to extend the browsers array with "Chrome", we need to
// always return a new empty array.
Object.defineProperty(overwrites, 'browsers', {
get: () => [],
set: () => {},
enumerable: true,
});
// Ensures that tests start executing once browsers have been manually connected. We need
// to use "defineProperty" because the default "@bazel/concatjs" config overwrites the option.
Object.defineProperty(overwrites, 'autoWatch', {
get: () => true,
set: () => {},
enumerable: true,
});
// When not running with ibazel, do not set up the `@bazel/concatjs` watcher. This one
// relies on ibazel to write to the `stdin` interface. When running without ibazel, the
// watcher will kill concatjs since there is no data written to the `stdin` interface.
if (process.env['IBAZEL_NOTIFY_CHANGES'] !== 'y') {
// We pre-define a plugins array that captures registration of Karma plugins
// and unsets the watcher definitions so that no watcher can be configured.
overwrites.plugins = new KarmaPluginArrayWithoutWatchers();
}
config.set(overwrites);
};
class KarmaPluginArrayWithoutWatchers extends Array {
// The Bazel Karma rules only register new plugins using `.push`.
push(...plugins) {
plugins.filter(p => typeof p === 'object').forEach(p => delete p.watcher);
super.push(...plugins);
}
}