lundi 1 février 2016

Make sure that all expects are called with Mocha / Chai

How do I make sure that every expect was called? For example the below test would pass even if the AccountManager.addAccount('tim', '123456'); would throw an error as the second expect is never called then.

Tape handles this with t.plan(2). Is there something in Mocha/Chai, too?

it.only('should test for taken username', done => {
    AccountManager.addAccount('kai', 'pazzword').then(result => {
      expect(result.ok).to.be.true;

      return AccountManager.addAccount('tim', '123456');
    }).then(result => {
      expect(result.ok).to.be.true;;

      return AccountManager.addAccount('kai', 'buzzword');
    }).catch(error => {
      done();
    });
});

Aucun commentaire:

Enregistrer un commentaire