Last active
September 7, 2018 04:24
-
-
Save ChristianRich/3c3fb3e61ba784b520afb08fdfa21270 to your computer and use it in GitHub Desktop.
Chai as promised - assess type Error and status code
This file contains hidden or 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
import { describe, it } from 'mocha'; | |
import chai, { expect } from 'chai'; | |
import chaiAsPromised from 'chai-as-promised'; | |
chai.use(chaiAsPromised); | |
describe('Example', () => { | |
it('should return 404', () => | |
expect(foo()).to.eventually.be.rejected | |
.and.be.an.instanceOf(Error) | |
.and.have.property('statusCode', 404)); | |
}); |
This file contains hidden or 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
it('should be fulfilled', () => | |
expect(service.foo()).to.be.fulfilled); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/29363455/test-a-rejection-with-chai-as-promised