websnap
1 min readAug 18, 2018

--

Is worth mentioning that you can do async tests using mocha’s way of handling async code and chai’s assertion style:

it(“should test async code”, done => {
const newUser = {posts: []};// 3 posts
myPromise() // returns the user
.then(user => {
//expected amount
const exAmount = newUser.posts.length;
assert.lengthOf(user.posts, exAmount);
done();
})
.catch( e => done(e) );
});

--

--

websnap

Front end developer, javascript enthusiast and GreenSock lover