Search code examples
javascriptnode.jsjasminejasmine-node

jasmine-node tests aren't running


I have a file word-count.js that looks like this:

    function words(statement) {
        words = {}
        //some code here that does stuff
        return words
    }

    module.exports = words;

and a test suite file called word-count_test.spec.js

var words = require('./word-count');

describe("words()", function() {
  it("counts one word", function() {
    var expectedCounts = { word: 1 };
    expect(words("word")).toEqual(expectedCounts);
  });
  // more tests ... 
});

The two files are in the same folder, yet when I run

$ jasmine-node word-count.js


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

Why aren't the tests working?


Solution

  • I was running jasmine-node on the wrong file.

    What I was doing (incorrect):

    jasmine-node word-count.js
    

    What I should be doing (correct):

    jasmine-node word-count_test.spec.js