Skip to content

Commit

Permalink
Fix ReactHooksInspection-test.js (#28520)
Browse files Browse the repository at this point in the history
## Summary

Currently, `ReactHooksInspection-test.js` fails because something is
polluting the resulting `Promise` with symbol properties. This changes
the unit test to be more resilient to such symbol properties.

## How did you test this change?

Ran the following successfully:

```
$ yarn test
```
  • Loading branch information
yungsters committed Mar 7, 2024
1 parent 447fc27 commit c35b9b0
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,24 +584,29 @@ describe('ReactHooksInspection', () => {
return <div>{value}</div>;
}
const tree = ReactDebugTools.inspectHooks(Foo, {});
expect(normalizeSourceLoc(tree)).toMatchInlineSnapshot(`
[
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": null,
"isStateEditable": false,
"name": "Unresolved",
"subHooks": [],
"value": Promise {},
const results = normalizeSourceLoc(tree);
expect(results).toHaveLength(1);
expect(results[0]).toMatchInlineSnapshot(
{
value: expect.any(Promise),
},
`
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
]
`);
"id": null,
"isStateEditable": false,
"name": "Unresolved",
"subHooks": [],
"value": Any<Promise>,
}
`,
);
});

describe('useDebugValue', () => {
Expand Down

0 comments on commit c35b9b0

Please sign in to comment.