5

I have a barebones spec written in coffeescript:

# test/foobar.spec.coffee

describe "falsy test", ->
  it "should fail", ->
    expect(true).toBe false

when I run jasmine-node --coffee test/foobar.spec.coffee from the project directory, I get the following error:

Exception loading: /Users/myuser/programming/project/test/foobar.spec.coffee
{ [Error: Cannot find module '/Users/myuser/programming/project/test/foobar.spec'] code: 'MODULE_NOT_FOUND' }

I am using:

node --version
v0.10.8

jasmine-node --version
1.13.0

Does anyone know why this is happening?

  • 1
    I have the same problem. jasmine-node says `Exception loading: /home/user/code/node-spec/transition_spec.coffee { [Error: Cannot find module '/home/user/code/node-spec/transition_spec'] code: 'MODULE_NOT_FOUND' }` – Matt Jan 30 '14 at 14:32
  • 1
    @Dmitry Kolobov It looks like this may have been resolved in the latest version. Try running 'npm update -g' from the command line to retrieve the latest version and then rerun your specs. – A-Dubb Feb 06 '14 at 18:40
  • @Dmitry Kolobov I'm currently using version 1.13.1. Check the output of 'jasmine-node --version'. – A-Dubb Feb 06 '14 at 18:42
  • @A-Dubb, it seems you are correct. With jasmine-node 1.14.3 everything works as expected. Thank you! – Dmitry Kolobov Jun 04 '14 at 00:03
  • @Dmitry Kolobov no problem. – A-Dubb Jun 17 '14 at 06:01

2 Answers2

0

I had a similar problem with other packages (require, supertest). It seems that if you install them globally (npm install -g) than you get this error. With a local installation (without -g option) everything seems to be normal.

Adam Bogdan Boczek
  • 1,720
  • 6
  • 21
  • 34
-1

I encountered this error in a weird way.

The following code works,

function someFunc(){
     //do something
}

describe(testCases.testCaseRegister.name, async function(){
    someFunc();

    //ensure ample time for database to be setup properly
    await new Promise(done => setTimeout(done, 5000));
}

But when i changed to this, the error will appear and occasionally, a "Syntax Error: await is only valid in async function"

function someFunc(){
     //do something
     await new Promise(done => setTimeout(done, 5000));
}

describe(testCases.testCaseRegister.name, async function(){
    someFunc();

}

Switching back to my original code, resolved all these errors.

winhung
  • 553
  • 1
  • 5
  • 19