grunt手表开始测试,但没有测试运行

时间:2013-08-26 20:30:23

标签: coffeescript gruntjs mocha watch

我有一个第一次正确运行的咕噜声任务(运行手写笔,转换咖啡,运行测试)。但是当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

编辑:根据吉拉德的建议,虽然没有区别:

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)
...

1 个答案:

答案 0 :(得分:3)

删除此内容:

options:        
  nospawn: true

(或者这个):

options:
  spawn: false

似乎解决了问题。错误报告here