Integration of Jasmine Spec framework with Node.js
Questions tagged [jasmine-node]
327 questions
52
votes
4 answers
How to run Jasmine tests on Node.js from command line
How do I run Jasmine tests on Node.js from command line? I have installed jasmine-node via npm and written some tests. I want to run tests inside the spec directory and get results in the terminal, is this possible?

PaolaJ.
- 10,872
- 22
- 73
- 111
50
votes
7 answers
jasmine tests in karma: Uncaught ReferenceError: require is not defined
Karma can not recognize 'require' statement in JSFileSpec.js file. Running karma.conf.js:
(function() {
describe("DummyEmitter creation", function(){
return it("creation", function(){
var DummyEmitter =…

Igor Seliverstov
- 525
- 1
- 5
- 7
38
votes
4 answers
Exporting classes with node.js
I have the following test code that is being ran by jasmine-node in a file called bob_test.spec.js
require('./bob');
describe("Bob", function() {
var bob = new Bob();
it("stating something", function() {
var result = bob.hey('Tom-ay-to,…

mattr-
- 5,333
- 2
- 23
- 28
14
votes
4 answers
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()…

Henrik N
- 15,786
- 5
- 82
- 131
12
votes
1 answer
Testing child process.send with Jasmine in Node.js
I have a Node.js application that has a main-process.js and a child-process.js.
The main-process.js looks like this:
var childProcess = require('child_process');
var job = childProcess.spawn('node', ["child-process.js"], {
detached = true,
…

Srivathsa
- 941
- 1
- 10
- 27
11
votes
2 answers
before/afterAll() is not defined in jasmine-node
I'm trying to use the methods beforeAll and afterAll of jasmine, to create a suite of tests with frisby.js, because actually, frisby doesn't have a support for this methods. So, this is what I'm trying to do:
var frisby =…

Pedro Henrique
- 609
- 2
- 9
- 26
10
votes
1 answer
How to force error branch in jasmine-node test
I'm testing the controller logic behind API endpoints in my node server with jasmine-node. Here is what this controller logic typically looks like:
var getSummary = function(req, res) {
var playerId = req.params.playerId;
…

MattDionis
- 3,534
- 10
- 51
- 105
10
votes
2 answers
Why does running `jasmine` after `jasmine init` and `jasmine examples` do nothing?
I have globally installed jasmine by running npm install jasmine -g.
Running jasmine -v gives me
jasmine v2.5.0
jasmine-core v2.5.0
I have then, as per the docs, run
jasmine init
jasmine examples
This created the expected /spec directory and the…

punkrockbuddyholly
- 9,675
- 7
- 36
- 69
10
votes
3 answers
Travis-CI with jasmine-node
I'm trying to get travis-ci to test my nodejs module with jasmine-node. When I run the tests from the commandline, they all pass, but for whatever reason, Travis always reports my build as failing. My .travis.yml looks like this:
language:…

thewildpendulum
- 1,255
- 1
- 13
- 19
9
votes
2 answers
jasmine-node done is not defined
Have been trying a simple async test. Installed jasmine-node npm install -g jasmine-node then wrote a simple module and test.
Simple module.
// weather.js
exports.get = function(city, callback) {
callback(city);
};
and a test suite.
//…

Mark Tyers
- 2,961
- 4
- 29
- 52
9
votes
2 answers
What's the correct way to use Jasmine from Node?
After much hacking, I've managed to get a simple Jasmine test running via Node.
However, there is some weird stuff I do not understand... The jasmine files export functions that appear to need a reference to themselves passed back in to work (this…

Danny Tuppeny
- 40,147
- 24
- 151
- 275
8
votes
2 answers
Protractor, Jasmine, and stopping test on first fail
While trying to figure out how to make certain jasmine expect statements dependent on a previous expect statement I discovered that previous to Jasmine 2.3.0, there was not a way. (see Stop jasmine test after first expect fails) However, Jasmine…

Machtyn
- 2,982
- 6
- 38
- 64
8
votes
1 answer
node js unit testing: mocking require dependency
I am having issues writing unit test for the following setup as a jira.js file (in a node.js module):
var rest = require('restler'); // https://www.npmjs.com/package/restler
module.exports = function (conf) {
var exported = {};
…

Rookie
- 5,179
- 13
- 41
- 65
8
votes
1 answer
Simulating stream `error` event for tests
I'm using the latest istanbul + jasmine-node to write all my test scripts.
In a few places I have a Readable stream that may emit error event, and I have no idea how to simulate such event in a test environment, to provide code coverage.
Can anybody…

vitaly-t
- 24,279
- 15
- 116
- 138
8
votes
4 answers
Strategy for testing POST to API without changing database
I'm using jasmine-node to test my API, and it has worked great for my GET routes. Now, however, I need to test some POSTs and I'm not sure how to go about this without changing my database.
One thought I had was to reset whatever value I change at…

MattDionis
- 3,534
- 10
- 51
- 105