0

I would like to use custom error message with Should.JS and while searching for solutions I came across this answer Apparently should does not support custom error messages at the moment

Currently I have been using Should.js version 3.3.2 and my code to use it is as follows.

var should = require('should');

Following the examples found in Chai documentation, I have changed my code to be the following.

var chai = require('chai');
var should = chai.should();

Having done so, I now have a bunch of broken tests and chai.should() is the culprit.

I kind of expected that chai.should() was really just a wrapper for Should.js and that it added filters/inteceptors so that you could configure useful extensions but when I inspect the object created by require('chai').should() against require('should') I notice that they are totally different api's

Here is some logging Code

var chai = require('chai');

var should = chai.should();
l.line('require("chai").should()');
l.inspect(should);
l.line('require("should")');
var shouldOriginal = require('should');
l.inspect(shouldOriginal);
console.log('----------------------------------------');

Log Output

Output

Tests are now failing on Should

Tests are now failing on Should

Please note that my real goal is just adding custom error messages to Should.JS

Community
  • 1
  • 1
David Cruwys
  • 6,262
  • 12
  • 45
  • 91
  • It is very bad idea to use both .getters from chai and shouldjs. It is by design in should.js to do not support custom messages (due to multilevel assertions). – den bardadym Dec 09 '15 at 07:07
  • I'm not attempting to use both at once, I'm just demonstrating that the API for Chai.should() is nothing like should.js which seems odd – David Cruwys Dec 09 '15 at 22:12
  • chai and should.js developed by different people. It looks pretty ok to have different API and/or different features. You are welcomed to should.js issues or gitter chat (i am should.js maintainer) with such questions. – den bardadym Dec 10 '15 at 07:20

0 Answers0