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
1
vote
1 answer

Mocha/Should.js using asynchronous function

I'm new to JavaScript test frameworks. I would like to do a little optimization but I run into some problems. The project is using should.js Here is the simplified version of my original test cases: describe('Simple', function() { describe('Test',…
iplus26
  • 2,518
  • 15
  • 26
1
vote
1 answer

Javascript deep object equality when object created via json string vs builder

I have some tests which call out to an HTTP API. I have mocked them out and am using a builder to create the relevant JSON so as to provide more meaning. I have used similar patterns in other languages and I am trying to get this working in…
Shifty
  • 113
  • 2
  • 7
1
vote
1 answer

What are the cases when should.deep.equal fails but comparison using JSON.stringify works fine?

A function returns an array of objects. When I compare the actual result with an expected result using JSON.stringify the values are identical. However comparison using should.deep.equal or _.isEqual fails. Had anyone encountered such issue?
Alexander Elgin
  • 6,796
  • 4
  • 40
  • 50
1
vote
0 answers

How to I write use mocha with should, chai

I use this demo for learn how to use mocha https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target here is my code, (with no error) // JavaScript source code var should = require('should'); var chai =…
bluelovers
  • 1,035
  • 2
  • 10
  • 22
1
vote
2 answers

What is the syntax to perform a custom test after a promise is fulfilled with should.js?

I am trying to express something like the following: it("should use the 'text' mode", () => { let usedMockMode = false; let env = new Environment(); let mockMode = { parse: () => usedMockMode = true }; env.modes.set("text",…
Lea Hayes
  • 62,536
  • 16
  • 62
  • 111
1
vote
2 answers

Mocha, should.js, and Promise catch callback

I am trying to assert a proper error message in an async promise failure test with mocha, but my test is not passing and I don't know why. Here's the code - the promise is 'use strict'; let getFailingPromise = function() { return new…
Zlatko
  • 18,936
  • 14
  • 70
  • 123
1
vote
1 answer

Mocha/Should 'undefined is not a function'

I'm going off of this tutorial, trying to make tests with Mocha, Supertest, and Should.js. I have the following basic test to create a user through a PUT endpoint that accepts it's data in headers. describe('User Routes', function () { …
Jackson
  • 559
  • 7
  • 20
1
vote
1 answer

Mocha unit tests and assertions in `for`loop

I'm working on Gulp plugin allowing to write JavaScript code using reserved words written in language different than English - its main doing is translating, yet it is not what I'm about. Writing unit tests with Mocha and Should.js I noticed I can't…
1
vote
2 answers

Why shouldjs says the two objects are not the same?

I'm new to coffeescript and I try to create a library for some added syntactic sugar for both cofffeescript and javascript. It uses a lot of decorators, so I'm surprised that this test fails: it 'sandbox', () -> id = (x) -> x fn = (y) -> y ==…
Luftzig
  • 523
  • 4
  • 14
1
vote
1 answer

Test environment and test database

Consider having a test database to run your tests on. One way of doing this is to set the database config through environment variables, and I see many people do so (example: Test environment in Node.js / Express application). However, to me…
swelet
  • 8,192
  • 5
  • 33
  • 45
1
vote
2 answers

Should.js - determine equality between a single field in multiple object's against a single object

I'm testing an api with the wonderful Mocha and Should.js. I do a GET and receive an array of objects, for example: [{ username: 'boris', something: 123 }, { username: 'jeremy', something: 456 }, { username: 'steven', something:…
Tony Barnes
  • 2,625
  • 1
  • 18
  • 29
1
vote
3 answers

Mocha and should assertion and not working as expected

I use Mocha and should as my test frameworks to node js modules. Until now Its works OK ,now I need to assert two object to equal. and I got error (test fail) while the object are the same (I use webStorm 10) and the Diff window show the two object…
user4445419
1
vote
1 answer

Superagent 'request' object is being redefined as function?

I'm trying to put together a supertest-based integration test suite (run by Mocha) that pings our REST API and validates the response. However, my test doesn't seem to be running as expected: var assert = require('assert') var should =…
Craig Otis
  • 31,257
  • 32
  • 136
  • 234
1
vote
3 answers

What is most readable way to do assert.fail() with should.js

As Should.js use BDD style of assertions, it suppose to be readable from the code. I am wondering what is the most readable assert.fail() equivalent for should.js. I am missing something like should.fail.
luboskrnac
  • 23,973
  • 10
  • 81
  • 92
1
vote
0 answers

Or'ing together should.js clauses

How do you create an or'd condition with should.js. i.e. something like cityName.should.startWith('A').or.companyName.should.startWith('B'); ... But this is not valid syntax. Either clause works fine independently but I don't know how to combine…
Jay Traband
  • 17,053
  • 1
  • 23
  • 44