Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@everett1992
Copy link

While working on
https://github.com/tschaub/mock-fs/blob/main/changelog.md#400 I noticed
that tests would timeout when some assertions failed because done was
never called.

promise.then(() => {
  assert(false)
  done()
}, done)

The issue is that then will only call one of it's two callbacks. The
onRejected function is not called when onFulfilled throws an error.

Switching to .catch(done) guarnatees the a rejected promise chain
marks the test as completed.

While working on
https://github.com/tschaub/mock-fs/blob/main/changelog.md#400 I noticed
that tests would timeout when some assertions failed because done was
never called.

```
promise.then(() => {
  assert(false)
  done()
}, done)
```

The issue is that `then` will only call one of it's two callbacks. The
onRejected function is not called when onFulfilled throws an error.

Switching to `.catch(done)` guarnatees the a rejected promise chain
marks the test as completed.
@tschaub
Copy link
Owner

tschaub commented Sep 26, 2024

Thank you, @everett1992. This was a long-standing oversight!

@tschaub tschaub merged commit 6225ba8 into tschaub:main Sep 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants