【问题标题】:Getting Jasmine to run on the server-side让 Jasmine 在服务器端运行
【发布时间】: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


【解决方案1】:

要么:

  • 确保您的 javascript 测试规范的扩展名是 .spec.js

或者

  • 将配置选项specNameMatcher替换为matchall: true

【讨论】:

  • 同样,我正在尝试在 /specs/**/*.coffee 中运行咖啡脚本测试,但我无法管理。有什么提示吗?
猜你喜欢
  • 1970-01-01
  • 2011-01-21
  • 1970-01-01
  • 2023-03-29
  • 2022-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多