Β» npm install jasmine-node
What is the purpose of jasmine-node?
Newest 'jasmine-node' Questions - Stack Overflow
How to run Jasmine tests on Node.js from command line - Stack Overflow
What's the correct way to use Jasmine from Node?
Videos
Β» npm install jasmine
Factsheet
/ 11 April 2026; 34 days ago (11 April 2026)
/ 11 April 2026; 34 days ago (11 April 2026)
This should get you going quickly:
- install Node.js (obviously).
Next install Jasmine. Open a command prompt and run:
npm install -g jasmineNext, cd to any directory and set up an example 'project':
jasmine init
jasmine examplesNow run your unit tests:
jasmine
If your jasmine.json file is somewhere else besides spec/support/jasmine.json, simply run:
jasmine JASMINE_CONFIG_PATH=relative/path/to/your/jasmine.json
For more info see:
- https://www.npmjs.com/package/jasmine
- http://jasmine.github.io/2.2/node.html
EDIT
It seems this is no longer the current best answer as the package is unmaintained. Please see the answer below
You can do this
from your test directory
Copysudo npm install jasmine-node
This installs jasmine into ../node_modules/jasmine-node
then
Copy../node_modules/jasmine-node/bin/jasmine-node --verbose --junitreport --noColor spec
which from my demo does this
CopyPlayer - 5 ms
should be able to play a Song - 2 ms
when song has been paused - 1 ms
should indicate that the song is currently paused - 0 ms
should be possible to resume - 0 ms
tells the current song if the user has made it a favorite - 1 ms
#resume - 0 ms
should throw an exception if song is already playing - 0 ms
Player - 5 ms
should be able to play a Song - 2 ms
when song has been paused - 1 ms
should indicate that the song is currently paused - 0 ms
should be possible to resume - 0 ms
tells the current song if the user has made it a favorite - 1 ms
#resume - 0 ms
should throw an exception if song is already playing - 0 ms
Finished in 0.01 seconds
5 tests, 8 assertions, 0 failures, 0 skipped
Pivatol recently added better node.js support to Jasmine in 2.0 and plans to release an official NPM package. For now you can use it from node by following the implementation used in their own node test suite.
Here is a brief explanation into what is happening under the covers in the code you wrote:
jasmine = jasmine.core(jasmine); When you initially require('jasmine') you are getting back a single function, getJasmineRequiredObj(); By calling jasmine.core(jasmine), you are tell jasmine to return it's behavioral methods using node exports statements instead of adding them onto the window.jasmineRequire object.
https://github.com/pivotal/jasmine/blob/master/src/core/requireCore.js
function getJasmineRequireObj() {
if (typeof module !== 'undefined' && module.exports) {
return exports;
} else {
window.jasmineRequire = window.jasmineRequire || {};
return window.jasmineRequire;
}
}
// jRequire is window.jasmineRequire in a browser or exports in node.
getJasmineRequireObj().core = function(jRequire) {
var j$ = {};
jRequire.base(j$);
j$.util = jRequire.util();
j$.Any = jRequire.Any();
...
return j$; // here is our jasmine object with all the functions we want.
};
jasmineConsole.console(jasmineConsole, jasmine) Jasmine initializes it's core functions separately from it's reporters. This statement is essentially the same thing as jasmine.core(jasmine) only for the console reporter.
https://github.com/pivotal/jasmine/blob/master/src/console/requireConsole.js
There is also jasmine-node (that still uses jasmine 1.3 and has a beta version with jasmine 2.0 - February 2015) and jasmine-npm (from the jasmine maintainers themselves, with the latest version).
Both of them are easy to use from the command line, with no code required (except the tests, of course!).
If you want to use jasmine tests for your Node.JS application just install jasmine-node.
Simply jasmine and jasmine-core the same packages cause it's link to the same github repository, they're for the simple js BDD tests.
jasmine-nodeis a third-party test runner, deprecatedjasmine-coreis a core library, not test runnerjasmineis the default test runner for Node.js
I also recommend to try humile which is alternative Jasmine test runner for Node.js with additional features.