茉莉花节点testing执行两次

我的茉莉花节点testing执行两次。

我从Grunt任务和Jasmine命令运行这些testing。 结果是一样的我的testing运行两次。 我的package.json:

{ "name": "test", "version": "0.0.0", "dependencies": { "express": "4.x", "mongodb": "~2.0" }, "devDependencies": { "grunt": "~0.4.5", "grunt-jasmine-node":"~0.3.1 " } } 

这是我的Gruntfile.js摘录:

  grunt.initConfig({ jasmine_node: { options: { forceExit: true, match: '.', matchall: true, extensions: 'js', specNameMatcher: 'spec' }, all: ['test/'] } }); grunt.loadNpmTasks('grunt-jasmine-node'); grunt.registerTask('jasmine', 'jasmine_node'); 

我的一个testing文件:

 describe("Configuration setup", function() { it("should load local configurations", function(next) { var config = require('../config')(); expect(config.mode).toBe('local'); next(); }); it("should load staging configurations", function(next) { var config = require('../config')('staging'); expect(config.mode).toBe('staging'); next(); }); it("should load production configurations", function(next) { var config = require('../config')('production'); expect(config.mode).toBe('production'); next(); }); }); 

我有4个断言的2个testing文件

这是我的提示:

 grunt jasmine Running "jasmine_node:all" (jasmine_node) task ........ Finished in 1.781 seconds 8 tests, 8 assertions, 0 failures, 0 skipped 

你有什么想法吗?

所有功劳均为1.618 。 他在这里回答了这个问题: 咕j茉莉节点testing运行两次

这看起来像一些马车行为。 快速修复就是像这样在你的Gruntfileconfigurationjasmine_node

 jasmine_node: { options: { forceExit: true, host: 'http://localhost:' + port + '/', match: '.', matchall: false, extensions: 'js', specNameMatcher: '[sS]pec' }, all: [] } 

关键是all参数。 grunt插件正在寻找名称中带有spec的文件。 出于某种原因,它看起来在spec/目录其他地方。 如果你指定spec目录,它的文件会被拾取两次。 如果你没有指定,它只会被设置一次,但是你不能把规范放在你的任何非testing文件名中。