Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Jasmine to run on the server-side

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

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

It just logs

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

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

Done, without errors.

This is my 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.

like image 321
bevacqua Avatar asked Mar 18 '13 18:03

bevacqua


1 Answers

Either:

  • Make sure the extension to your javascript test specs is .spec.js

Or

  • Replace the configuration option specNameMatcher with matchall: true
like image 51
bevacqua Avatar answered Oct 31 '22 13:10

bevacqua