Grunt + Watch + Jasmine工作一次,第二次失败

时间:2014-07-10 10:39:59

标签: node.js gruntjs jasmine

这是我的Grumodule.exports = function(grunt){

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      serve: {
        files: ['server.js', 'src/**/*.coffee'],
        tasks: ['coffee', 'develop', 'jasmine'],
        options: {
          nospawn: true
        }
      },
      test: {
        files: ['tests/*.spec.js', 'src/**/*.coffee'],
        tasks: ['coffee', 'jasmine_node'],
        options: {
          nospawn: true
        }
      }
    },

    jasmine_node: {
      options: {
        forceExit: true,
        match: '.',
        matchall: false,
        extensions: 'js',
        specNameMatcher: 'spec',
        jUnit: {
          useDotNotation: true,
          consolidate: true
        }
      },
      all: ['tests/']
    },
    develop: {
      server: {
        file: 'server.js'
      }
    },
    coffee: {
      compile: {
        expand: true,
        bare: true,
        cwd: 'src/',
        src: ['**/*.coffee'],
        dest: 'lib/',
        ext: '.js'
      }
    },
    copy: {
      main: {
        expand: true,
        cwd: 'src/views/',
        src: ['**'],
        dest: 'lib/views/'
      }
    },

    less: {...}
  });

  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-jasmine-node');
  grunt.loadNpmTasks('grunt-develop');
  // grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('serve', ['coffee', 'develop', 'watch:serve']);
  grunt.registerTask('test', ['coffee', 'jasmine_node', 'watch:test']);
  grunt.registerTask('build', ['coffee', 'less']);
  grunt.registerTask('templates', ['copy']);

};

当我跑$ grunt test时:

Running "coffee:compile" (coffee) task

Running "jasmine_node:all" (jasmine_node) task

mods
    ... [all good]

Finished in 0.211 seconds
19 tests, 60 assertions, 0 failures



Running "watch:test" (watch) task
Waiting...
>> File "tests/mods.spec.js" changed. // I JUST ADDED A BLANK LINE

Running "coffee:compile" (coffee) task

Running "jasmine_node:all" (jasmine_node) task
...

[Some goods, other wrong]

Failures:

  1) ...

  2) ...

  3) ..

Finished in 5.26 seconds
19 tests, 57 assertions, 3 failures

为什么呢?我必须确切地说,我使用mockgoose来测试

0 个答案:

没有答案