There's more...

The expect assertions within Chai are known as Behavior Driven Development (BDD). This style of assertion is completely oriented around the behavior of your application's state, and is written in a manner that makes it very easy to understand which behavior is being tested for. Chai also supports another BDD style assertion keyword, the should assertion:

let should = chai.should();

Foobar.should.be.a('string');
Foobar.should.equal('foobar');
Foobar.should.have.lengthOf(6);

http.get(123, function (err, data) {
should.not.exist(err);
should.exist(data);
data.should.be.an('object');
});

The should assertion is an alternative way in Mocha to write the same types of Chai assertions as the expect assertion keyword, but with what some consider a more naturally readable BDD style.

You can learn more about assertion styles in Chai though the official Chai documentation website at http://chaijs.com/guide/styles/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.101.192