我们运行Jasmine测试时遇到问题。如果我们运行:
ng test --browsers=ChromeHeadless --code-coverage
测试正在进行中。
但是,如果我们运行:
ng test --watch=false --browsers=ChromeHeadless --code-coverage
它不起作用,我们得到这个错误:
$ npm run test:noWatch
> [email protected] test:noWatch E:\Jenkins\home\workspace\MSF-Test\monatlicheschueler\client
> ng test --watch=false --browsers=ChromeHeadless --code-coverage
14 02 2019 15:28:47.979:INFO [karma]: Karma v3.0.0 server started at http://0.0.0.0:9876/
14 02 2019 15:28:47.995:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
14 02 2019 15:28:48.027:INFO [launcher]: Starting browser ChromeHeadless
14 02 2019 15:29:09.146:INFO [HeadlessChrome 0.0.0 (Windows 8.1 0.0.0)]: Connected on socket 5cSIZU4-5deTyQyKAAAA with id 46249460
14 02 2019 15:29:39.153:WARN [HeadlessChrome 0.0.0 (Windows 8.1 0.0.0)]: Disconnected (1 times), because no message in 30000 ms.
HeadlessChrome 0.0.0 (Windows 8.1 0.0.0) ERROR
Disconnected, because no message in 30000 ms.
HeadlessChrome 0.0.0 (Windows 8.1 0.0.0) ERROR
Disconnected, because no message in 30000 ms.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:noWatch: `ng test --watch=false --browsers=ChromeHeadless --code-coverage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:noWatch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
我们正在使用这个版本:
Angular CLI: 7.3.1
Node: 10.14.1
OS: win32 x64
Angular: 7.1.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.4
@angular-devkit/build-angular 0.12.4
@angular-devkit/build-optimizer 0.12.4
@angular-devkit/build-webpack 0.12.4
@angular-devkit/core 7.2.4
@angular-devkit/schematics 7.3.1
@angular/cdk 7.1.1
@angular/cli 7.3.1
@angular/material 7.3.2
@ngtools/webpack 7.2.4
@schematics/angular 7.3.1
@schematics/update 0.13.1
rxjs 6.3.3
typescript 3.1.6
webpack 4.28.4
这是我在日志中可以找到的:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'test:noWatch' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest:noWatch', 'test:noWatch', 'posttest:noWatch' ]
5 info lifecycle [email protected]~pretest:noWatch: [email protected]
6 info lifecycle [email protected]~test:noWatch: [email protected]
7 verbose lifecycle [email protected]~test:noWatch: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~test:noWatch: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\Jenkins\home\workspace\MSF-Test\monatlicheschueler\client\node_modules\.bin;C:\Users\admin2\bin;E:\Program Files\Git\mingw64\bin;E:\Program Files\Git\usr\local\bin;E:\Program Files\Git\usr\bin;E:\Program Files\Git\usr\bin;E:\Program Files\Git\mingw64\bin;E:\Program Files\Git\usr\bin;C:\Users\admin2\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;E:\Program Files\Git\cmd;C:\Program Files\nodejs;E:\Program Files\7-Zip;C:\Windows\System32;E:\Program Files\maven\apache-maven-3.5.4\bin;E:\Program Files\commons-daemon;E:\Program Files\Git\usr\bin;E:\Program Files\Git\usr\bin;E:\Program Files\Git\mingw64\bin;E:\Program Files\Java\jdk1.8.0_171\bin;C:\Users\admin2\AppData\Roaming\npm;E:\Program Files\Git\usr\bin\vendor_perl;E:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle [email protected]~test:noWatch: CWD: E:\Jenkins\home\workspace\MSF-Test\monatlicheschueler\client
10 silly lifecycle [email protected]~test:noWatch: Args: [ '/d /s /c',
10 silly lifecycle 'ng test --watch=false --browsers=ChromeHeadless --code-coverage' ]
11 silly lifecycle [email protected]~test:noWatch: Returned: code: 1 signal: null
12 info lifecycle [email protected]~test:noWatch: Failed to exec test:noWatch script
13 verbose stack Error: [email protected] test:noWatch: `ng test --watch=false --browsers=ChromeHeadless --code-coverage`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid [email protected]
15 verbose cwd E:\Jenkins\home\workspace\MSF-Test\monatlicheschueler\client
16 verbose Windows_NT 6.3.9600
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test:noWatch"
18 verbose node v10.14.1
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] test:noWatch: `ng test --watch=false --browsers=ChromeHeadless --code-coverage`
22 error Exit status 1
23 error Failed at the [email protected] test:noWatch script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
有人知道可能是什么问题吗?
用--watch false
测试不相等,在版本6中有一个问题,不知道是否修复
问题是超时,我需要将它添加到我的karma.conf.js
captureTimeout: 210000,
browserDisconnectTolerance: 3,
browserDisconnectTimeout : 210000,
browserNoActivityTimeout : 210000
谢谢你的帮助。 :)