Skip to content

fix timeout in failing test#390

Merged
tschaub merged 1 commit intotschaub:mainfrom
everett1992:done
Sep 26, 2024
Merged

fix timeout in failing test#390
tschaub merged 1 commit intotschaub:mainfrom
everett1992:done

Conversation

@everett1992
Copy link
Copy Markdown

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
Copy Markdown
Owner

tschaub commented Sep 26, 2024

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

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