Skip to content
Snippets Groups Projects
Commit fe3458e3 authored by Winnie Hellmann's avatar Winnie Hellmann
Browse files

Minor changes to Testing Promises section

parent e4eec191
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -74,7 +74,7 @@ When testing Promises you should always make sure that the test is asynchronous
Your Promise chain should therefore end with a call of the `done` callback and `done.fail` in case an error occurred.
 
```javascript
/// Good
// Good
it('tests a promise', (done) => {
promise
.then((data) => {
Loading
Loading
@@ -84,9 +84,10 @@ it('tests a promise', (done) => {
.catch(done.fail);
});
 
/// Good
// Good
it('tests a promise rejection', (done) => {
promise
.then(done.fail)
.catch((error) => {
expect(error).toBe(expectedError);
})
Loading
Loading
@@ -94,7 +95,7 @@ it('tests a promise rejection', (done) => {
.catch(done.fail);
});
 
/// Bad (missing done callback)
// Bad (missing done callback)
it('tests a promise', () => {
promise
.then((data) => {
Loading
Loading
@@ -102,7 +103,7 @@ it('tests a promise', () => {
})
});
 
/// Bad (missing catch)
// Bad (missing catch)
it('tests a promise', (done) => {
promise
.then((data) => {
Loading
Loading
@@ -111,7 +112,7 @@ it('tests a promise', (done) => {
.then(done)
});
 
/// Bad (use done.fail in asynchronous tests)
// Bad (use done.fail in asynchronous tests)
it('tests a promise', (done) => {
promise
.then((data) => {
Loading
Loading
@@ -121,7 +122,7 @@ it('tests a promise', (done) => {
.catch(fail)
});
 
/// Bad (missing catch)
// Bad (missing catch)
it('tests a promise rejection', (done) => {
promise
.catch((error) => {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment