Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix test for older node.js version
Browse files Browse the repository at this point in the history
mondaychen committed Apr 1, 2022
1 parent ce34cfe commit 19cb6e5
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
@@ -686,6 +686,8 @@ function handleRenderFunctionError(error: any): void {
// Note: This error name needs to stay in sync with react-devtools-shared
// TODO: refactor this if we ever combine the devtools and debug tools packages
wrapperError.name = 'ReactDebugToolsRenderError';
// this stage-4 proposal is not supported by all environments yet.
wrapperError.cause = error;
throw wrapperError;
}

Original file line number Diff line number Diff line change
@@ -281,10 +281,8 @@ describe('ReactHooksInspection', () => {
try {
ReactDebugTools.inspectHooks(Foo, {}, FakeDispatcherRef);
} catch (error) {
// first argument is the error message
expect(error.message).toBe('Error rendering inspected component');
// The second arg is the options object with the cause, which is the
// original error
// error.cause is the original error
expect(error.cause).toBeInstanceOf(Error);
expect(error.cause.message).toBe(
"Cannot read property 'useState' of null",
Original file line number Diff line number Diff line change
@@ -924,10 +924,7 @@ describe('ReactHooksInspectionIntegration', () => {
try {
ReactDebugTools.inspectHooksOfFiber(childFiber, FakeDispatcherRef);
} catch (error) {
// first argument is the error message
expect(error.message).toBe('Error rendering inspected component');
// The second arg is the options object with the cause, which is the
// original error
expect(error.cause).toBeInstanceOf(Error);
expect(error.cause.message).toBe(
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +

0 comments on commit 19cb6e5

Please sign in to comment.