Questions tagged [jasmine-node]

Integration of Jasmine Spec framework with Node.js

327 questions
8
votes
5 answers

grunt jasmine-node tests are running twice

I set up grunt to run node.js jasmine tests. For some reason, with this config, the results always show double the tests. Here is my config: I'm using jasmine-node which plugs into grunt. /spec/some-spec.js: var myModule =…
d-_-b
  • 21,536
  • 40
  • 150
  • 256
8
votes
4 answers

Automate Jasmine-Node and express.js

I created a simple Webapp using express.js and want to test it with jasmine-node. Works fine so far but my problem is that I have to start the server manually every time before I can run my tests. Could you help me on how to write a spec-helper that…
optikfluffel
  • 2,538
  • 4
  • 20
  • 27
8
votes
2 answers

Testing asynchronous mongodb calls in nodejs with jasmine-node

I am using jasmine-node to run tests against my nodejs functions. Being new to nodejs and mongodb, the first thing i ran into was testing some database calls, and I immediately got stuck, due to the asynchronous nature of nodejs. What I want to do…
Marcel Kalveram
  • 1,295
  • 1
  • 14
  • 22
7
votes
3 answers

How to show passed test in Jasmine?

When running jasmine it only presents dot(.) for successful tests, and only verbose if the test fails. //test.spec.js describe('jasmine', ()=>{ it('should show this text', () =>{ }); }) My running command is: jasmine-node test.spec.js The…
Sang
  • 4,049
  • 3
  • 37
  • 47
7
votes
4 answers

how do I run a single test from the command line using jasmine 2.0

As the title says, I would like to run a single test, not the whole spec. The naive way I tried was using a case like this: describe("MyCase",function() { it("has a test",function() { expect(something).toBe(something); } it("has…
Mikael Lindqvist
  • 775
  • 5
  • 21
6
votes
1 answer

How to mock a module that is required in another module with Jasmine

const Client = require('./src/http/client'); module.exports.handler = () => { const client = new Client(); const locationId = client.getLocationId(123); }; How can I test this module asserting that the client.getLocationId has been called…
kekko12
  • 566
  • 1
  • 6
  • 19
6
votes
1 answer

Function is called after promise is resolved but Jasmine fails the test. Why?

My application uses a service that returns a promise that is typically dependant on a whole bunch of other promises. I've refactored this into seperate named functions to make testing (and readability) easier. So in this case I just want to test…
spryce
  • 616
  • 7
  • 14
6
votes
1 answer

How to spyOn global timers like clearInterval or setInterval in jasmine-node tests?

I'm writing tests on my server side code which is in nodejs. The tests are written in jasmine 2. I'm running the tests using grunt-jasmine-nodejs. The server side code uses the timers like setInterval and clearInterval. I want to spy on these timers…
SMahadev
  • 61
  • 1
  • 4
6
votes
1 answer

What is the purpose of jasmine-node?

I can run my specs with either jasmine-node or just jasmine. They both run my specs. So, what value does jasmine-node add? The readme says: This node.js module makes the wonderful Pivotal Lab's jasmine spec framework available in node.js. …
Jared Beck
  • 16,796
  • 9
  • 72
  • 97
6
votes
1 answer

How to Test PUT method using supertest and jasmine-node

I am building an API with expressjs and my routes look like this module.exports = function(app){ var book = require('../controllers/book.controller'); app.get('/api/books', book.getBooks); //get all books app.post('/api/books', book.addBook); //add…
Jibolash
  • 648
  • 1
  • 9
  • 14
6
votes
3 answers

How to run jasmine-node tests with RequireJS

How can I properly run jasmine tests using jasmine-node and RequireJS? I already tried something like this, but doesnt work (CoffeeScript): requirejs = require 'requirejs' requirejs.config { baseUrl: __dirname + '/../' } requirejs ['MyClasses',…
Martin
  • 490
  • 5
  • 16
5
votes
2 answers

No specs found while executing jasmine test via bazel

I'm tring to run jasmine test using bazel on my current directory, but it is complaining about no specs found. I think it has something to do with the "srcs" variable that I am providing. I tried [":spec/test.spec.ts"] and [":spec"] but none is…
qrb
  • 89
  • 4
5
votes
2 answers

How to use jasmine with gulp.watch

I'm trying to make my tests run each time I'm saving some files. Here is the gulp watch: gulp.task('jasmine', function() { gulp.src('spec/nodejs/*Spec.js') .pipe(jasmine({verbose:true, includeStackTrace: true})); }); gulp.task('watch', function…
toutpt
  • 5,145
  • 5
  • 38
  • 45
5
votes
2 answers

jasmine-node cannot find spec module

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…
5
votes
4 answers

how to unit test the backbone success and error response on save using jasmine

onSaveEvent: function (event) { if (this.model !== null) { var that = this; this.model.save(this.model.toJSON(), { success: function (model) { …
Gururaj
  • 1,115
  • 2
  • 14
  • 17
1
2
3
21 22