Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix timeout in failing test #390

Merged
merged 1 commit into from
Sep 26, 2024
Merged

fix timeout in failing test #390

merged 1 commit into from
Sep 26, 2024

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