Assertions

Assert . Should . Expect . Must

Traditional method of writing tests vs The ability to write and read tests like a sentence.

Argument: If you can read your tests fluidly, you will naturally write better and more comprehensive tests.

Should, Expect and Must interfaces all utilize the BDD assertion styles which provide chainable getters to improve the readability of your assertions.

The question then is which assertion library excels in writing assertions as close to natural language as possible.

All the above interfaces use the same chaining words and so this can not be used as an indicator.

Maybe we can use the structure of the assertions in each interface to make our decision.

Should and Must interface are similar in that they extend the Object.Prototype to provide a single getter as the starting point of the language assertions.

As a result when making an assertion the coder can access the must or should property of the object and then call the desired matcher.

See the following example:

var should = require('should'); 
var company = {name: 'QW',location: ['LA', 'Jamaica']};
company.should.have.property('name').with.lengthOf(2);
 
var must = require("must/register");
var sum =1+43;
sum.must.equal(44);
 

Notice that should and must are accessed as properties of the object itself. On the other hand, the expect interface provides a function as a starting point of the language assertions.

See the following example: 

var expect = require('expect');
var name = 'bar'
expect(name).toBeA('string'); 

Even though the structures are different, all assertions still seem to read like sentences and so it can therefore be concluded that no BDD assertion style depicts natural language more than the other.