【发布时间】:2015-04-03 11:32:13
【问题描述】:
我有以下设置:
package.json
"scripts": {
"test": "jest"
}
gulpfile.js
gulp.task('test', shell.task('npm test'));
当我运行 npm test 时,它会运行一次测试并停止。
但是,运行 gulp test 会导致运行测试两次。请参阅下面的日志。
为什么会发生这种情况,您将如何解决?
日志:
$ gulp test
[14:12:28] Using gulpfile e:\react-playground\gulpfile.js
[14:12:28] Starting 'test'...
> react-playground@1.0.0 test e:\react-playground
> jest
Using Jest CLI v0.2.2
Waiting on 1 test...
FAIL search-panel\questions\__tests__\questions-test.js (1.145s)
● Questions › it should render content
- Expected: 'Hi! Questions here' toEqual: 'Hi! Questions here2'
at new jasmine.ExpectationResult (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:115:32)
at null.toEqual (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:1236:29)
at Spec.<anonymous> (e:\react-playground\src\search-panel\questions\__tests__\questions-test.js:14:55)
at jasmine.Block.execute (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:1065:17)
at jasmine.Queue.next_ (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:2098:31)
at null._onTimeout (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:2088:18)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
1 test failed, 0 tests passed (1 total)
Run time: 1.416s
npm ERR! Test failed. See above for more details.
npm[14:12:30] 'test' errored after 2.32 s
[14:12:30] Error in plugin 'gulp-shell'
Message:
Command failed: npm ERR! Test failed. See above for more details.
npm
Details:
killed: false
code: 1
signal: null
stdout:
> react-playground@1.0.0 test e:\react-playground
> jest
Using Jest CLI v0.2.2
Waiting on 1 test...
FAIL search-panel\questions\__tests__\questions-test.js (1.145s)
● Questions › it should render content
- Expected: 'Hi! Questions here' toEqual: 'Hi! Questions here2'
at new jasmine.ExpectationResult (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:115:32)
at null.toEqual (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:1236:29)
at Spec.<anonymous> (e:\react-playground\src\search-panel\questions\__tests__\questions-test.js:14:55)
at jasmine.Block.execute (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:1065:17)
at jasmine.Queue.next_ (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:2098:31)
at null._onTimeout (e:\react-playground\node_modules\jest-cli\vendor\jasmine\jasmine-1.3.0.js:2088:18)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
1 test failed, 0 tests passed (1 total)
Run time: 1.416s
stderr: npm ERR! Test failed. See above for more details.
npm
【问题讨论】:
-
在我看来测试运行了一次,然后由于脚本失败,npm 报告了标准输出和标准错误。请注意括号中标记的时间戳。另请注意,报告的“运行时间”在两个输出中完全相同。如果测试运行不止一次,我不会想到。
-
@RandyMorris 我试过
gulp test 2>/dev/null,但没有帮助。我开始怀疑gulp-shell,因为日志中的这一行:“插件'gulp-shell'中的错误”。任何想法如何解决这个问题?
标签: npm gulp jestjs gulp-shell