Skip to content

Instantly share code, notes, and snippets.

@ChristianRich
Last active September 7, 2018 04:24
Show Gist options
  • Save ChristianRich/3c3fb3e61ba784b520afb08fdfa21270 to your computer and use it in GitHub Desktop.
Save ChristianRich/3c3fb3e61ba784b520afb08fdfa21270 to your computer and use it in GitHub Desktop.
Chai as promised - assess type Error and status code
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));
});
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