Closed alpha0010 closed 4 months ago
@alpha0010 thank you for reporting this.
As far as I can see:
unmount
for cleanup queue: https://github.dev/callstack/react-native-testing-library/blob/main/src/cleanup.tsafterEach
Jest event: https://github.com/callstack/react-native-testing-library/blob/4e148bdb0573fcb86686482c3af1d1e02e1cc937/src/index.ts#L13What you are doing in the workaround is that you are calling unmount()
directly in the test, so before afterEach
. That causes the useEffect
cleanup be called inside the test, and not in "after test" phase.
I'm not sure if cleanup could technically be called by RNLT "inside" the test, as that is controlled by Jest (and you as the user). So the manual unmount()
workaround seems the best we can do now. Let me know if you see other options.
Closing as stale. Workaround available (manual calling of unmount
.
Describe the bug
While running tests, I get:
This appears to be due to the
useEffect()
cleanup being called after Jest has done its own cleanup; manuallyunmount()
ing the component before exiting the test resolves the issue.This is problematic since
jest --runInBand
exits non-zero, causing pipeline failures (even though all tests pass).Expected behavior
Automatic cleanup has access to the Jest environment, so I do not need to manually
unmount()
.Steps to Reproduce
Screenshots
Versions