我遇到一个问题,在我选择的开发设置中(使用gitlab-runner和docker执行karma-runner进行测试的docker),Phantom.js浏览器开始吐出动画错误(更多信息:https://github.com/angular/material2/issues/14210)。由于puppeteer大约有280mb,所以我不想在运行器管道上用它替换phantomjs。有没有办法执行每个规格文件之前,包括全局模块?这样我可以通过导入NoopAnimationsModule停止动画。
从gitlab-runner管道中导出。
PhantomJS 2.1.1 (Linux 0.0.0) LayoutComponent should create FAILED
TypeError: undefined is not an object (evaluating 'getAnimationStyle(element, '').trim') in http://localhost:9876/_karma_webpack_/vendor.js (line 5211)
applyKeyframeAnimation@http://localhost:9876/_karma_webpack_/vendor.js:5211:46
apply@http://localhost:9876/_karma_webpack_/vendor.js:5170:31
init@http://localhost:9876/_karma_webpack_/vendor.js:5334:27
play@http://localhost:9876/_karma_webpack_/vendor.js:5340:18
play@http://localhost:9876/_karma_webpack_/vendor.js:4858:95
http://localhost:9876/_karma_webpack_/vendor.js:4638:24
<Jasmine>
_flushAnimations@http://localhost:9876/_karma_webpack_/vendor.js:4631:28
flush@http://localhost:9876/_karma_webpack_/vendor.js:4280:48
flush@http://localhost:9876/_karma_webpack_/vendor.js:5128:37
http://localhost:9876/_karma_webpack_/vendor.js:135595:35
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11874:31
onInvoke@http://localhost:9876/_karma_webpack_/vendor.js:208197:45
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11873:60
run@http://localhost:9876/_karma_webpack_/polyfills.js:11633:49
runOutsideAngular@http://localhost:9876/_karma_webpack_/vendor.js:78855:31
end@http://localhost:9876/_karma_webpack_/vendor.js:135593:41
end@http://localhost:9876/_karma_webpack_/vendor.js:85716:30
detectChanges@http://localhost:9876/_karma_webpack_/vendor.js:83201:23
_tick@http://localhost:9876/_karma_webpack_/vendor.js:86262:45
http://localhost:9876/_karma_webpack_/vendor.js:86276:54
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11874:31
onInvoke@http://localhost:9876/_karma_webpack_/vendor.js:208197:45
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11873:60
onInvoke@http://localhost:9876/_karma_webpack_/vendor.js:78896:39
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11873:60
run@http://localhost:9876/_karma_webpack_/polyfills.js:11633:49
run@http://localhost:9876/_karma_webpack_/vendor.js:78810:31
detectChanges@http://localhost:9876/_karma_webpack_/vendor.js:86276:28
http://localhost:9876/_karma_webpack_/main.js:6430:30
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11874:31
onInvoke@http://localhost:9876/_karma_webpack_/vendor.js:208197:45
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11873:60
run@http://localhost:9876/_karma_webpack_/polyfills.js:11633:49
runInTestZone@http://localhost:9876/_karma_webpack_/vendor.js:208418:37
http://localhost:9876/_karma_webpack_/vendor.js:208433:33
<Jasmine>
http://localhost:9876/_karma_webpack_/vendor.js:208734:35
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11874:31
onInvoke@http://localhost:9876/_karma_webpack_/vendor.js:208197:45
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11873:60
run@http://localhost:9876/_karma_webpack_/polyfills.js:11633:49
http://localhost:9876/_karma_webpack_/vendor.js:208733:32
http://localhost:9876/_karma_webpack_/vendor.js:208565:45
invokeTask@http://localhost:9876/_karma_webpack_/polyfills.js:11906:36
runTask@http://localhost:9876/_karma_webpack_/polyfills.js:11678:57
invokeTask@http://localhost:9876/_karma_webpack_/polyfills.js:11981:41
invoke@http://localhost:9876/_karma_webpack_/polyfills.js:11970:52
timer@http://localhost:9876/_karma_webpack_/polyfills.js:13764:34
PhantomJS 2.1.1 (Linux 0.0.0): Executed 5 of 10 (1 FAILED) (0 secs / 2.575 secs)
PhantomJS 2.1.1 (Linux 0.0.0): Executed 6 of 10 (1 FAILED) (0 secs / 3.274 secs)
PhantomJS 2.1.1 (Linux 0.0.0): Executed 7 of 10 (1 FAILED) (0 secs / 4.01 secs)
PhantomJS 2.1.1 (Linux 0.0.0): Executed 8 of 10 (1 FAILED) (0 secs / 4.069 secs)
PhantomJS 2.1.1 (Linux 0.0.0): Executed 9 of 10 (1 FAILED) (0 secs / 4.112 secs)
PhantomJS 2.1.1 (Linux 0.0.0): Executed 10 of 10 (1 FAILED) (0 secs / 4.457 secs)
PhantomJS 2.1.1 (Linux 0.0.0): Executed 10 of 10 (1 FAILED) (4.896 secs / 4.457 secs)
TOTAL: 1 FAILED, 9 SUCCESS
我如何解决此问题而无需切换到puppeteer,因为这将显着更改运行程序的图像大小,并且执行时间会慢很多倍。有没有办法在特定的.spec文件的测试平台之前包含要导入的全局模块?