Last active
February 11, 2020 16:10
-
-
Save Siilwyn/13b3811608f645d4827f787a04ea4f37 to your computer and use it in GitHub Desktop.
Comparison of testing promises with Jest & Ava
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
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')) | |
) |
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
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