0

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?

ApathyBear
  • 9,057
  • 14
  • 56
  • 90
  • Whats the output when you run it `--verbose`? – jmunsch Apr 08 '15 at 00:23
  • @jmunsch Same, but gives off `undefined`. Problem? – ApathyBear Apr 08 '15 at 00:40
  • Are there any asynchronous operations in the code you've removed? Whenever I'm trying to test my asserts are firing I add something like `expect(1).toBe(2)` to make sure it fails as expected before even worrying about my application logic. – Terry Apr 08 '15 at 01:36
  • As far as I know, the `spec` file should be placed inside a `spec/` folder. Then running `jasmine-node spec/` should do the job. – Rodrigo Medeiros Apr 08 '15 at 02:47
  • I think I realized what the issue is. I can't believe I overlooked this. See my answer. – ApathyBear Apr 08 '15 at 07:16

1 Answers1

0

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
ApathyBear
  • 9,057
  • 14
  • 56
  • 90