Created
November 11, 2016 13:13
-
-
Save zhentian-wan/601e15e702ee6b1f0fccb718ede21116 to your computer and use it in GitHub Desktop.
Testing promise with mocha & chai as promised
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chai = require('chai'); | |
const expect = chai.expect; | |
const chaiAsPromised = require('chai-as-promised'); | |
const index = require('../index.js'); | |
chai.use(chaiAsPromised); | |
describe('Function foo', () => { | |
it('should accpet anything but one', () => { | |
const promise = index.foo(0); | |
return expect(promise).to.eventually.equal(0); | |
}); | |
it('should throw error is apply one', () => { | |
const promise = index.foo(1); | |
// return expect(promise).to.be.rejected; | |
return expect(promise).to.be.rejectedWith('Found an error'); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment