Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jasmine-node says "0 tests" when there *are* tests

I expect this to say "1 test", but it says "0 tests". Any idea why? This is on OS X.

$ jasmine-node --verbose my.spec.js
undefined

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

$ cat my.spec.js
describe("bar", function() {
  it("works", function() {
    expect("foo").toEqual("foo");
  });
});

$ jasmine-node --version
1.11.0  
$ npm --version
1.3.5  
$ node -v
v0.4.12

Even if I try to create a syntax error I get the same output:

$ cat my.spec.js
it(
$ jasmine-node --verbose --captureExceptions my.spec.js
undefined

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

But if I try to specify a file that doesn't exist, it complains:

$ jasmine-node no.spec.js
File: /tmp/no.spec.js is missing.
like image 292
Henrik N Avatar asked Aug 10 '13 14:08

Henrik N


People also ask

How do I test in node js with Jasmine?

In order to test a Node. js application, the jasmine framework needs to be installed first. This is done by using the Node package manager. The test code needs to be written in a separate file, and the word 'spec' should be appended to the file name.

What is Jasmine Nodejs?

NODE AND BROWSER Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests. Get Started.


2 Answers

I also had this problem, it was that I didn't name the file correctly:

your specification files must be named as spec.js, spec.coffee or spec.litcoffee, which matches the regular expression /spec.(js|coffee|litcoffee)$/i; otherwise jasmine-node won't find them! For example, sampleSpecs.js is wrong, sampleSpec.js is right.

Source: https://github.com/mhevery/jasmine-node

like image 81
edi9999 Avatar answered Oct 18 '22 04:10

edi9999


You should upgrade to the latest version of nodejs (currently 0.10.15)

like image 1
SheetJS Avatar answered Oct 18 '22 06:10

SheetJS