【发布时间】:2013-03-19 03:17:06
【问题描述】:
我正在尝试使用 Node.JS 在服务器端测试 JavaScript
我正在使用grunt 和grunt-jasmine-node,但我无法让它运行我的测试。
它只是记录
PS C:\Development\NET\Source\jsn> grunt 运行“jasmine_node”任务 未定义
在 0.001 秒内完成 0 次测试、0 次断言、0 次失败
完成,没有错误。
这是我的Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jasmine_node: {
specNameMatcher: 'spec',
projectRoot: '.',
requirejs: false,
forceExit: true,
jUnit: {
report: false,
savePath : "./build/reports/jasmine/",
useDotNotation: true,
consolidate: true
}
}
});
grunt.loadNpmTasks('grunt-jasmine-node');
grunt.registerTask('default', 'jasmine_node');
};
我的文件结构是这样的:
那么,我做错了什么?
这就像 stub.js 文件甚至没有加载,因为它有一个 console.log 调用来测试它。
【问题讨论】:
-
我无法帮助您解决您的问题,但作为替代方案,您可以尝试 Grunt 团队的 Jasmine 插件:github.com/gruntjs/grunt-contrib-jasmine。
-
grunt-contrib-jasmine 在浏览器 (PhantomJS) 中运行测试。它对在节点上运行测试没有帮助。
标签: javascript node.js unit-testing jasmine gruntjs