Skip to content

Commit

Permalink
docs: remove .catch(t.threw) advice
Browse files Browse the repository at this point in the history
This is no longer necessary.  Unhandled rejections are sent to the
active test's threw() method by the async-hook-domain.
  • Loading branch information
isaacs committed May 30, 2019
1 parent ee6454e commit 0ce8811
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions docs/promises/index.md
Expand Up @@ -18,11 +18,8 @@ or failed when it is rejected.
These two features together mean that you can string together Promise
chains in your tests, if that's a thing you're into.

If you do use a lot of Promises to chain your tests in a long
declarative list, it's a good idea to put `.catch(t.threw)` at the
end, so that any unhandled rejections will be bubbled up to the top
level handler rather than being ignored or reported in a less helpful
manner.
Unhandled promise rejections will be fail the active test, just like thrown
errors would.

Here is an example:

Expand All @@ -45,7 +42,6 @@ t.test('get thing', t =>
t.equal(otherPromiseResult, 7, 'it should be seven')
t.end()
})))
.catch(t.threw)
```

If this sort of style offends you, you are welcome to ignore it. It's
Expand Down Expand Up @@ -85,7 +81,7 @@ t.test('get thing', async t => {
t.equal(otherPromiseResult, 7, 'it should be seven')
t.end()
})
}).catch(t.threw)
})
```

Because subtests return promises, you can also `await` them to do
Expand Down

0 comments on commit 0ce8811

Please sign in to comment.