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

How to add custom success message in Mocha tests?

I have a loop inside a test case where I repeat a part of the test for each data sample. How can I add a custom sucess message indicating that specific data, representing a test case, was sucessful? For instance, my code is like: it('Should not…
RedDragon
  • 2,080
  • 2
  • 26
  • 42
0
votes
1 answer

How to dynamically test for typeof array within object?

I have an user object - I want to generate test for each user property and check if it's the right type. However as typeof array is an object assertion fails on array properties with "AssertionError: expected [ 1 ] to be an object". I have…
t-str-os
  • 57
  • 6
0
votes
2 answers

Mocking out with Sinon.js a dependency to be injected

Having the following balanceRepository.js file. module.exports = function(){ this.getBalance = (accountId)=>{ throw 'NotImplementedException'; };}; And the service transactionService.js file. module.exports =…
osotorrio
  • 960
  • 1
  • 11
  • 30
0
votes
1 answer

How to use should.js as global variable:

I am trying to write some unit test that using mocha and should.js since I would like to keep format for each of my unit test the same and each unit test require should.js to verify proerpty of object. How can I make it as globally variable so I do…
jacobcan118
  • 7,797
  • 12
  • 50
  • 95
0
votes
1 answer

TypeError: should is not a function

I have recently upgraded to Angular 6 and all the tests that ran fine fail with the following error TypeError: should is not a function I am using Angular-Cli 6 and my best guess is this is because appropriate typings aren't available for 'should'…
lohiarahul
  • 1,432
  • 3
  • 22
  • 35
0
votes
1 answer

ShouldJs Typescript issues with promises

I'm getting a compile error in typescript with shouldjs only when trying to use the .rejected() / .fufilled() syntax Promise.resolve().should // is fine, is an Assertion Promise.resolve().should.rejected // is fine, is a…
Lev Kuznetsov
  • 3,520
  • 5
  • 20
  • 33
0
votes
2 answers

Should not working as expected

I am new to Should testing. Always used Assert but I'm trying new options. This simple test is not working and I am curious to understand why. Profile.js class Profile { constructor(profile_name,user_name,email,language) { …
Ed de Almeida
  • 3,675
  • 4
  • 25
  • 57
0
votes
1 answer

Same types but still error on global declaration "TS2717: Subsequent property declarations must have the same type with same type."

Version 13.2.1 of the library should produces the following error when compiling with TypeScript 2.7.1 on Node 8.9.1: node_modules/should/should.d.ts(237,5): error TS2717: Subsequent property declarations must have the same type. Property 'should'…
Koslun
  • 2,164
  • 1
  • 23
  • 17
0
votes
0 answers

Issues creating a Unit Test stub for this function return using Sinon and Should

I have the following health.js file.. exports.endpoint = function (req, res) { let http_status = 200; res.sendStatus(http_status); }; Where I'm trying to figure out how I can create a Unit Test from this endpoint. Below is my attempt so…
TheAuzzieJesus
  • 587
  • 9
  • 23
0
votes
1 answer

Error when trying to read JSON array using Should, Mocha, & Supertest

I have the following JSON payload: "app": { "name": "myapp", "version": "1.0.0", "last_commit": { "author_name": "Jon Snow" "author_email": "my@email.com" } } and the following .js file (using Mocha, Supertest and…
TheAuzzieJesus
  • 587
  • 9
  • 23
0
votes
2 answers

Node.js & Mocha/Should (JavaScript, ES6): Code not executed although it looks like it should

I trying to write some test code in a nodejs project using mocha/should and request. My code initializes an array with some web addresses in order to send a GET request to a remote server and check the content of the responses. My mock-up right now…
Sauerkraut
  • 75
  • 1
  • 9
0
votes
2 answers

Chai assertion, unable to identify property using should / expect

Hello: Need your help on a chai assertion. I have a JSON response as shown below. I want to assert that it contains "Lastname is mandatory" only. I tried using this statement but the error i get is AssertionError: expected [ Array(2) ] to have a…
Bipo K
  • 395
  • 3
  • 20
0
votes
1 answer

How would I go about deleting a particular field within a JSON for a test, then reloading the JSON in another test without caching the delete?

Okay, so here's my issue: it('should fail when Sns is not found within record', (done) => { const policy = require('../main/nacl-002-handler.js'); const eventData = require('./data/event.json'); delete…
Sam S.
  • 348
  • 1
  • 3
  • 15
0
votes
1 answer

assert that an object is an integer number

Using should.js, I am currently doing: ordinal.should.be.a.Number().and.equal(Math.floor(ordinal)); … is there a more concise way to require that a given object be an integer?
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
0
votes
1 answer

Using Testdouble.js to stub API call and resolve a promise

I'm using testdouble.js to test a couple functions. For the below function, I'm struggling to figure out how to best stub the get API call in order to cover the remainder of function. It seems like it should be straightforward, but I think I've…