简体   繁体   English

让Jasmine在服务器端运行

[英]Getting Jasmine to run on the server-side

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. 我正在使用gruntgrunt-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: 我的文件结构是这样的:

enter image description here

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调用来测试它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM