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
36
votes
6 answers

How to check if two files have the same content?

I am using mocha/supertest/should.js to test REST Service GET /files/ returns file as stream. How can I assert in should.js that file contents are the same? it('should return file as stream', function (done) { var writeStream =…
hellboy
  • 1,567
  • 6
  • 21
  • 54
33
votes
5 answers

Should js Cannot read property 'should' of null

i try to use the testing tool mocha in node. Consider the following test scenario var requirejs = require('requirejs'); requirejs.config({ //Pass the top-level main.js/index.js require //function to requirejs so that node modules //are…
softshipper
  • 32,463
  • 51
  • 192
  • 400
21
votes
4 answers

Where should unit tests be placed in Meteor?

Is there a place where my tests can live without being run by Meteor? I just started my first Meteor project, and began by writing unit tests with Mocha and should.js. Though mocha runs without a problem, the tests prevent Meteor from starting up…
Blackcoat
  • 3,280
  • 30
  • 25
14
votes
1 answer

How can I make should.js assertions about dates?

I've got a unit test like this: (parsed.date).should.equal(new Date(2006,06,18,18,07)); Which fails with this message: AssertionError: expected 2006-07-19T00:07:00.000Z to be 2006-07-19T00:07:00.000Z + expected - actual What am I doing wrong?
Sam Mikes
  • 10,438
  • 3
  • 42
  • 47
12
votes
1 answer

ChaiJS Should - test for empty string

According to docs on the shouldJS site I should be able to do this: ''.should.be.empty(); The ChaiJS site doesn't have an example with should syntax, but it lists it for expect and it seems that the above example would work. However this…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
11
votes
4 answers

Node mocha array should contain an element

I want to do a simple assertion of something like knownArray.should.include('known value') The array is correct, but I simply can't figure out the proper assertion to use to check whether the array has this value (the index doesn't matter). I also…
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
10
votes
1 answer

Mocha: assertions within promise not working

So, I'm completely new to mocha, and promises and I was asked to write integration tests, which posts form data to a page, gets an authentication key, and then run tests on the key. I'm getting the key back properly, which is confirmed by my log…
I11umin8
  • 103
  • 1
  • 6
10
votes
1 answer

How does one do a deepEqual assertion with should.js?

I've tried to make a deepEqual assertion with should.js (the latest version) and have not had any success. I can get things to work with equal but not with deepEqual. In fact I am seeing that there is no deepEqual method. Here's what I've tried: >…
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
8
votes
1 answer

Can I use should.js with QtScript?

I'm using QtScript to automate parts of my application for development and testing purposes. I've come to the point where I want to test assertions, and based on "standalone assertion libraries?" and what I could find in Debian repositories, I went…
Toby Speight
  • 27,591
  • 48
  • 66
  • 103
8
votes
2 answers

Using should.js how can I test for an empty object?

user1Stats.should.be.instanceof(Object); (user1Stats).should.have.keys(); I get the following error: Error: keys required at Object.Assertion.keys The instanceof(Object) works, but I want to make sure there is no data in it.
chovy
  • 72,281
  • 52
  • 227
  • 295
8
votes
2 answers

Mocha, should.js and asserting an exception

I have a file app.coffee: class TaskList class Task constructor: (@name) -> @status = 'incomplete' complete: -> if @parent? and @parent.status isnt 'completed' throw "Dependent task '#{@parent.name}' is not…
Matthew
  • 15,282
  • 27
  • 88
  • 123
7
votes
2 answers

Suppress REST Logging Calls from Supertest

I have started using MEAN stack and currently writing REST unit tests using Super Test I want to have a little bit more clarity in my log file so that I can easily see my successful and failed tests. I wish to suppress the console output for the…
David Cruwys
  • 6,262
  • 12
  • 45
  • 91
7
votes
4 answers

res.should.have.status gives me error

I'm new to mocha and should.js. I'm trying to check the response's status but it gives me TypeError: Object # has no method 'status' The code is like this: describe('Local signup', function() { it('should return error trying to save…
Charlie
  • 81
  • 1
  • 7
7
votes
1 answer

Organising tests using Mocha & Should.js

I'm new to unit testing using the Mocha & should.js. I'm using the Mocha's BDD for testing my application. The application I'm testing has different components like account, products & order. Before moving the code to the git repository I want to…
sunilkumarba
  • 851
  • 2
  • 9
  • 18
6
votes
3 answers

Should.js: check if two arrays contain same strings

I have two arrays: var a = ['a', 'as', 'sa']; var b = ['sa', 'a', 'as']; Is there anything special in shouldJS to test if these two arrays have same items? Anything Like should(a).be.xyz(b) that can test them? Here, xyz is what I am looking for.
Samman Bikram Thapa
  • 1,037
  • 12
  • 15
1
2 3
9 10