Skip to content

Instantly share code, notes, and snippets.

@Siilwyn
Last active February 11, 2020 16:10
Show Gist options
  • Save Siilwyn/13b3811608f645d4827f787a04ea4f37 to your computer and use it in GitHub Desktop.
Save Siilwyn/13b3811608f645d4827f787a04ea4f37 to your computer and use it in GitHub Desktop.
Comparison of testing promises with Jest & Ava
test('expect a reject', (t) =>
rejectSomething()
.then(t.fail)
.catch(error => t.is(error, 'bla'))
)
test('expect a resolve', (t) =>
resolveSomething()
.then(result => t.is(result, 'hey'))
)
test('expect a reject', (done) => {
rejectSomething()
.then(done.fail)
.catch(error => {
expect(error).toBe('bla')
done()
})
})
test('expect a resolve', () =>
resolveSomething()
.then(result => expect(result).toBe('hey'))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment