react-hooks-testing-library: TypeError: Cannot destructure property 'error' of 'results[(results.length - 1)]' as it is undefined. [Suspense]
react-hooks-testing-libraryversion: 5.0.2reactversion: 17.0.1react-domversion (if applicable): 17.0.1react-test-rendererversion (if applicable):17.0.1nodeversion:14.13.1npm(oryarn) version:1.22.5
Relevant code or config:
expect(result.error).toBe(null);
What you did:
Directly after the renderHooks() line with a function that throws a Promise
What happened:
Reproduction:
result.error just after a hook that suspends (don’t await the resolution of suspense).
result.current was fixed in https://github.com/testing-library/react-hooks-testing-library/commit/dc21e5947a54adfaf348bfeaeab56d37a4e7e2bb but result.error was not.
Problem description:
Suspense is the most important use of this library
Suggested solution:
Do the thing in https://github.com/testing-library/react-hooks-testing-library/commit/dc21e5947a54adfaf348bfeaeab56d37a4e7e2bb but apply to all members
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 64 (64 by maintainers)
Oh wow, I didn’t realize it wasn’t actually a promise. I kinda expected typescript to complain about awaiting something that isn’t a promise. Well, thanks for all your help - upgrade complete! 😃
rerender() is what i can use to reset error boundary?
Thanks so much for the investigation - this looks to be super helpful. Unfortunately I have to wrap up some other stuff for now so I have to put a pause on this til probably end of the week. I’ll update on whatever I find there. Thanks again!