【发布时间】:2013-08-29 10:29:38
【问题描述】:
我有一个第一次正确运行的繁重任务(运行手写笔、转换咖啡、运行测试)。但是当watch 任务启动时,它运行mochaTest:all 任务但没有运行测试。
配置:
grunt.initConfig
watch:
coffee:
files: ['app/assets/src/coffee/**/*.coffee', 'app/assets/src/coffee/*.coffee', 'app/webserver.coffee']
tasks: ['coffee:dev', 'replace', 'mochaTest:all']
options:
nospawn: true
test:
files: ['test/calc/*.coffee', 'test/*.coffee']
tasks: ['test']
options:
nospawn: true
stylus:
files: 'app/assets/src/styl/**/*.styl'
tasks: 'stylus:dev'
mochaTest:
all:
src: [ 'test/calc/*.coffee', 'test/*.coffee']
options:
reporter: 'nyan'
timeout: 1000
...
grunt.registerTask "test", [ "mochaTest"]
直接运行测试:
$ grunt 'mochaTest'
Running "mochaTest:all" (mochaTest) task
...
264 passing (10 seconds)
好的,这样就可以了。但是当手表被触发时,不会运行任何测试:
Waiting...
OK
>> File "test/dataLayer-test.coffee" changed.
Running "mochaTest:all" (mochaTest) task
0 passing (1 ms)
没有运行测试。我一定有什么配置错误。这里有什么问题?这是一个错误吗?
版本:
$ npm list | grep grunt
├─┬ grunt@0.4.1
├── grunt-contrib-coffee@0.7.0
├── grunt-contrib-stylus@0.5.0
├─┬ grunt-contrib-watch@0.5.1
├─┬ grunt-mocha-test@0.6.3
├── grunt-text-replace@0.3.2
编辑:根据 Gilad 的建议,但没有区别:
grunt watch --verbose --debug
...
Running "mochaTest:all" (mochaTest) task
[D] Task source: /home/dev/projects/alpha/node_modules/grunt-mocha-test/tasks/mocha.js
Verifying property mochaTest.all exists in config...OK
Files: test/calc/calc-test.coffee, ...
264 passing (9 seconds)
5 pending
>> File "test/ui-formulaEditor-test.coffee" changed.
Running "mochaTest:all" (mochaTest) task
[D] Task source: /home/dev/projects/alpha/node_modules/grunt-mocha-test/tasks/mocha.js
Verifying property mochaTest.all exists in config...OK
Files: test/calc/calc-test.coffee, ...
0 passing (2 ms)
...
【问题讨论】:
-
运行
grunt watch --verbose --debug。在我看来,从手表运行的 mochaTest 似乎没有得到正确的参数。另外 - nospawn 是一个旧参数。使用产卵。 -
@GiladPeleg 没有变化,更新问题
-
spawn: false 或 nospawn: true 表示手表将在同一上下文中运行任务。我建议使用默认值,特别是使用测试套件生成任务。
-
@KyleRobinsonYoung 彻底解决这个问题似乎已经解决了。
标签: coffeescript gruntjs mocha.js watch