Skip to content

Commit 384ce51

Browse files
devversionmmalerba
authored andcommitted
build: fix unit test local target being killed by ibazel watcher
Currently when trying to debug a unit test locally using the Bazel `_local` target for web tests, the Karma instance is getting killed (if the test runs without ibazel) due to the Karma iBazel watcher being registered accidentally. We fixed this in the past by disabling the watcher, but the Karma NodeJS rules have changed and we need to adjust our monkey-patch so that the watcher is not registered.
1 parent 0e3bd88 commit 384ce51

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/bazel-karma-local-config.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* want to launch any browser and just enable manual browser debugging.
44
*/
55

6-
const bazelKarma = require('@bazel/concatjs');
7-
86
module.exports = config => {
97
const overwrites = {};
108

@@ -30,8 +28,21 @@ module.exports = config => {
3028
// relies on ibazel to write to the `stdin` interface. When running without ibazel, the
3129
// watcher will kill concatjs since there is no data written to the `stdin` interface.
3230
if (process.env['IBAZEL_NOTIFY_CHANGES'] !== 'y') {
33-
delete bazelKarma['watcher'];
31+
// We pre-define a plugins array that captures registration of Karma plugins
32+
// and unsets the watcher definitions so that no watcher can be configured.
33+
overwrites.plugins = new KarmaPluginArrayWithoutWatchers();
3434
}
3535

3636
config.set(overwrites);
3737
};
38+
39+
class KarmaPluginArrayWithoutWatchers extends Array {
40+
// The Bazel Karma rules only register new plugins using `.push`.
41+
push(...plugins) {
42+
plugins
43+
.filter(p => typeof p === 'object')
44+
.forEach(p => delete p.watcher);
45+
46+
super.push(...plugins);
47+
}
48+
}

0 commit comments

Comments
 (0)