showing results for - "chai expect async throw"
Alexandre
16 Feb 2019
1const chai = require('chai')
2const expect = chai.expect
3chai.use(require('chai-as-promised'))
4
5// Always succeeds
6async function wins() {
7  return 'Winner'
8}
9
10// Always fails with an error
11async function fails() {
12  throw new Error('Contrived Error')
13}
14
15it('wins() returns Winner', async () => {
16  expect(await wins()).to.equal('Winner')
17})
18
19it('fails() throws Error', async () => {
20  await expect(fails()).to.be.rejectedWith(Error)
21})