How to add chaijs assert to mocha mocha.opts file?

I do not know if this is possible. I know if we just use the should.js library we can do the following in a mocha.optsfile

--require should

But since it chaiis a parent module, but asserta submodule chai, how do I need it in a file mocha.opts?

Or am I missing something really basic?

+4
source share
2 answers

AFAIK chai mocha . should, should , , , .

-, :

global.assert = require('chai').assert;

mocha.opts --require global-chai-assert, chai assert . , , , .

+6

chai v4.0.0 assert// :

require('chai/register-assert');  // Using Assert style
require('chai/register-expect');  // Using Expect style
require('chai/register-should');  // Using Should style

, mocha.opts:

--require chai/register-should

README Chai Repo.

0

All Articles