让Jasmine在服务器端运行

时间:2021-08-16 15:39:17

I'm trying to get started on testing JavaScript on the server-side with Node.JS

我正在尝试开始使用Node.JS在服务器端测试JavaScript

I'm using grunt, and grunt-jasmine-node, but I can't get it to run my tests.

我正在使用grunt和grunt-jasmine-node,但我无法让它运行我的测试。

It just logs

它只是记录

PS C:\Development\NET\Source\jsn> grunt Running "jasmine_node" task undefined

PS C:\ Development \ NET \ Source \ jsn> grunt运行“jasmine_node”任务未定义

Finished in 0.001 seconds 0 tests, 0 assertions, 0 failures

完成0.001秒0次测试​​,0次断言,0次失败

Done, without errors.

完成,没有错误。

This is my Gruntfile.js

这是我的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');
};

And my file structure is this:

我的文件结构是这样的:

让Jasmine在服务器端运行

So, what am I doing wrong?

那么,我做错了什么?

It's like the stub.js file isn't ever even loaded, because it has a console.log call in it to test that.

这就像stub.js文件甚至没有被加载,因为它有一个console.log调用来测试它。

1 个解决方案

#1


6  

Either:

  • Make sure the extension to your javascript test specs is .spec.js
  • 确保您的javascript测试规范的扩展名为.spec.js

Or

  • Replace the configuration option specNameMatcher with matchall: true
  • 用matchall:true替换配置选项specNameMatcher

#1


6  

Either:

  • Make sure the extension to your javascript test specs is .spec.js
  • 确保您的javascript测试规范的扩展名为.spec.js

Or

  • Replace the configuration option specNameMatcher with matchall: true
  • 用matchall:true替换配置选项specNameMatcher