jasminejasmine-node

jasmine vs jasmine-node test differences


I have been using jasmine and today I thought I would try jasmine-node. Some of the passing tests for jasmine fail in jasmine-node. Specifically, toBeLessThanOrEqual is not a function in jasmine-node. Is jasmine-node something that should be avoided?


Solution

  • The difference is the version of jasmine that is being used. With jasmine-node they use version 1.3.1 currently, while jasmine itself is much further along (currently at version 3.2). Since jasmine has had a couple of major version changes, there are breaking changes between them which explains why your tests that use jasmine 2.x or 3.x might not work with jasmine-node because the syntax is different.

    Until jasmine-node updates to use a newer version of jasmine you would be stuck with the jasmine 1.x syntax, which isn't great.

    Note that if you want to use istanbul for code coverage you'd also have to force it to used the same jasmine version that your tests are written with.

    While jasmine-node can be convenient, I prefer to use the latest jasmine syntax so can't use it as it is.