tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
911 stars 86 forks source link

fix timeout in failing test #390

Closed everett1992 closed 2 months ago

everett1992 commented 2 months ago

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 commented 2 months ago

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