Questions tagged [should.js]

should is an expressive, readable, test framework agnostic, assertion library for node.

should is an expressive, readable, test framework agnostic, assertion library for node.

GitHub project: https://github.com/visionmedia/should.js

API reference: http://shouldjs.github.io/

149 questions
2
votes
1 answer

How do I reuse a test function with async calls in nodejs?

I'm new to node.js and it's been a while since I've worked with an asynchronous framework. In a procedural language such as python it's easy to have a list of inputs and expected outputs then to loop through them to test: tests = { 1: [2, 3], 2:…
JivanAmara
  • 1,065
  • 2
  • 10
  • 20
2
votes
2 answers

Why is typescript compiler omitting 'should.js' import in generated javascript?

I am facing a weird issue. In my (lets say) a.ts I have - /// /// import should = require('should'); import something_else =…
Vinayak Garg
  • 6,518
  • 10
  • 53
  • 80
2
votes
1 answer

mocha should expect a timeout, call done() when timed out

I'm trying to write a test for socket. I'm using passport.socketio and so socket shouldn't be connected (and thus the socket callback never fired) when there's no logged in user. I want to test that. Is there a way to actually expect a…
laggingreflex
  • 32,948
  • 35
  • 141
  • 196
2
votes
1 answer

Best practice for decoupling queries from testing

I'm looking for best practices for testing mysql queries with mocha or sinon. I'm trying to test very basic DB queries such as save: User.prototype.save = function(cb) { var query = 'INSERT INTO user (name, email, password, img, description)' …
BBS
  • 1,351
  • 2
  • 12
  • 27
2
votes
1 answer

How to extend 'should' library

I would like o introduce to should assert library, working for tests of my node.js app, my additional functions. Something like in this pseudocode should = require "should" myExists = (obj, msg) -> # my special exist…
Luman75
  • 878
  • 1
  • 11
  • 28
2
votes
2 answers

Testing asynchronous middleware functionality with Mongoose

I'm using a save middleware in Mongoose to create a log of activity in the DB whenever some action is taken. Something like UserSchema.post("save", function (doc) { mongoose.model("Activity").create({activity: "User created: " +…
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
2
votes
1 answer

Mocha.js and Should.js to test express.js app

How can I use Mocha.js and Should.js to effectively test that my express.js app is sending the correct data back? The reason I ask is that sometimes, if req.xhr we send back the same data but in a different format, depending on the extension from…
James
  • 5,137
  • 5
  • 40
  • 80
2
votes
1 answer

timeout exceeded error in Async Mocha tests

I am using Mocha and should for testing simple database queries, I am trying to run Async tests for simple Moongose schema functions, but I am getting timeout exceeded error everytime. Error: timeout of 15000ms exceeded at null.
Suleman Mirza
  • 905
  • 1
  • 12
  • 22
2
votes
0 answers

extending shouldjs methods (mocha + node)

In my mocha/should functional tests I find myself often writing el.is(':visible').should.eql true Since I do it so much I was thinking it might make sense to extend should so I can do something like this: el.should.beVisible() That would allow me…
Simon Lang
  • 40,171
  • 9
  • 49
  • 58
2
votes
2 answers

Use of should.js with Coffeescript

I want to use should.js together with mocha in a Node.js projects which I write in Coffeescript. In pure Javascript a expression in should.js is like (function(){ throw new Error('fail'); }).should.throw(); Now I want to write the same expression…
rotespferd
  • 315
  • 1
  • 5
  • 10
2
votes
2 answers

Why "should.strictEqual" in should.js doesn't work?

According to should.js Spec this should work: should.strictEqual(shape.code, code) but I get: TypeError: Object # has no method 'strictEqual' What am I missing?
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
1
vote
1 answer

Error unit tests using (mocha , chai) in nodejs

I have an error when I run a test: mocha test.js. This is the error : const chaiHttp = require('chai-http'); const sinon = require('sinon'); const sinontest = require('sinon-test'); const test = sinontest(sinon); const chai = require('chai'); const…
mitsu
  • 429
  • 2
  • 10
  • 23
1
vote
0 answers

Mocha/Chai TypeError: Cannot read property 'include' of undefined

So I have this super simple Chai test that keeps failing for reasons I don't understand. Here is my code: let chaiHttp = require('chai-http'); const helpers = require('../lib/helpers.js'); let chai = require('chai'); let should =…
1
vote
2 answers

How to disable should.js override "should" property?

One of the external libraries we're using is having a property called "should" in one of its classes. When we run tests with shouldjs it seems like should instruments its class with its "should" which crashes the library. How can we hint shouldjs…
Guy Korland
  • 9,139
  • 14
  • 59
  • 106
1
vote
1 answer

Why is should.be.type() failing with "TypeError: (intermediate value).should.be.type is not a function"

I do not understand why the following test is failing with the error: TypeError: (intermediate value).should.be.type is not a function describe('#Option object', function() { it('returns value as whatever type was passed to the constructor',…
scubasteve
  • 2,718
  • 4
  • 38
  • 49