Closed dieseldjango closed 1 year ago
Thanks for raising this issue.
If you feel strongly about it, please feel free to raise a PR to fix it (I think your suggestion here is fine, or even just setting a noop
default value for restoreConsole
so it is always defined), but in general this library should be considered somewhat deprecated now and folks should be migrating across to testing-library/react
instead (where they do not hijack the console output like we do).
Given the status of the library and that the error only happens if beforeEach()
throws an error anyway, I don't think this is worth fixing.
react-hooks-testing-library
version: 7.0.2 (but code is same in main branch)react
version: 17.0.1node
version: 18.14.0yarn
version: 1.22.19Relevant code or config:
In core/console.js:
What you did:
Wrote a test with a
beforeEach()
that throws an error.What happened:
Reproduction:
Don't have this yet, I can create if necessary, but I think the fix is pretty simple.
Problem description:
I'm using jest 27.5.1, and apparently the way it works, if my test throws an error in its
beforeEach()
, yourbeforeEach()
that is setup inenableErrorOutputSuppression()
is not called. However, yourafterEach()
is still called, and throws an error becauserestoreConsole()
is undefined.Suggested solution: