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
4
votes
1 answer

Testing Errors passed back with Callbacks with mocha and should

UPDATE 2-July-2013 Using the last approach with the wrapped anonymous function can introduce some strange testing behavior. If you expect a thrown error, but there is an error in the actual execution the test will pass, but will pass on any error…
Modika
  • 6,192
  • 8
  • 36
  • 44
4
votes
1 answer

callback being called twice when my unit test fails

I can't figure out why my save callback is being called twice in my mocha test when the callback fails. It doesn't call the save twice, it only fires the callback for the save again but with the 'should' error when my 2nd unit test fails. If I…
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460
3
votes
0 answers

Mocha retry doesn't work with should.js for async calls

I'm trying to use mocha retry for async test and it doesn't seem to work. when the test fail (in the context of the callback) it will not call done() and therefore the retry doesn't work. I have already many tests written this way and i need a…
shay lang
  • 31
  • 1
3
votes
1 answer

Does there exist a shouldjs function that mimics should.throws for promises?

I am writing a test suite that tests promise-returning functions. One common theme of these tests is the need to check if a promise-returning functions properly throws an error when passed invalid arguments. I have tried using should.throws, but in…
almel
  • 7,178
  • 13
  • 45
  • 58
3
votes
0 answers

I want to integrate code coverage for a javascript api project (build with node and express)

This is the open sorce project https://github.com/telepat-io. I want to attach integration testing with code coverage. The tests are build with mocha an should.js . I have tried istanbul, codeclever, blanket, grunt. nothing worked. They all give me…
ventura8
  • 554
  • 6
  • 18
3
votes
1 answer

test express API requires local server

I've read i can run mocha test in an Express application (nodeJS) with super test and therefore it is not required to run the app in a different terminal session. Whatever i try it always ends with a connection error. To configure our continuous…
Peter Van de Put
  • 878
  • 10
  • 26
3
votes
1 answer

How to refactor a "callback pyramid" into promise-based version

I'm currently struggeling to really understand how to refactor my code to use promises/the Q library. Consider the following common basic example: I have a testcase that imports the same file twice into a mongodb and then checks whether the dataset…
Florian
  • 271
  • 3
  • 14
3
votes
2 answers

How to handle should.js assert error

How should one handle uncaught exception thrown by a should.js (or node.js) failed assertion and keep execution on the same function/block where the assertion failed? I tried wrapping the assertion in a try/catch but it seems to go up to…
dublx
  • 11,978
  • 1
  • 14
  • 11
2
votes
3 answers

How to Assert from multiple possibilities in Cypress? One option could be true out of multiple

I have a scenario, where i need to put Assertion on an element's text which could be true OR pass the test case, if the any 1 value is present out of many. Let say, an element can contain multiple status' : 'Open', 'Create', 'In Progress' any of…
Amit Verma
  • 109
  • 7
2
votes
1 answer

cypress.should contains with regex with variable and substring

How can I use regular expression with variable and substring in cypress.should to verify url by typescript? something like? const string = /key_to_be_include\w+key1__`${v1}`,key2__`${v2}`/ //url:…
jacobcan118
  • 7,797
  • 12
  • 50
  • 95
2
votes
1 answer

Node.js "should" library assertion, how does it work?

Our Mocha test suite has this line: model.getResourceDependencies.should.be.a.Function; the test code uses the should library as you can see the above expression is neither an assignment nor an invocation, or is it? How does this work? Is there…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
2
votes
1 answer

Proper promises error handling at mocha tests

I'm using Mongoose with promises by wrapping it this way with bluebird's method: var mongoose = promise.promisifyAll(require('mongoose')) Then I'm trying to use an async method: var newUser = new User({email: 'd@a.com', password: '123', userType:…
diegoaguilar
  • 8,179
  • 14
  • 80
  • 129
2
votes
2 answers

Test should pass on stream error, fail on success

I'm trying to write a mocha test which passes on a stream error but fails if the stream ends without an error. Detecting the error is no problem, but the finish handler is always called, even if the stream is forced to error out. In this code, the…
joemaller
  • 19,579
  • 7
  • 67
  • 84
2
votes
2 answers

Mocha async test handle errors

I'm trying to create a test case with Mocha but my code is asynchronous. That's fine, I can add a "done" callback function to "it" and that will work perfectly fine for positive cases. But when trying to test negative cases, it will just make the…
nico
  • 144
  • 12
2
votes
1 answer

Using should.js how to check whether a string is not present in an array?

Like to check whether a string is present in an array we do someArray.should.contain('str'), but I can't find the negation case check for this.
Koustuv Sinha
  • 1,640
  • 19
  • 34
1 2
3
9 10