Bug: ReactFlightAsyncDebugInfo test 'can track async information when awaited' fails due to snapshot mismatch
React version:Experimental / latest commit
Steps To Reproduce
- Clone the React repository.
- Run the following test: yarn test packages/react-server/src/tests/ReactFlightAsyncDebugInfo-test.js --testNamePattern="can track async information when awaited" --runInBand --verbose
- Observe that the test fails due to a snapshot mismatch.
https://github.com/user-attachments/assets/426920b1-7338-4d5d-833e-22e33a7d5c4c
-->
Link to code example: packages/react-server/src/tests/ReactFlightAsyncDebugInfo-test.js
Context: Snapshot Mismatch in ReactFlightAsyncDebugInfo-test
Failing Test Case
test("can track async information when awaited", async () => {
const result = await someAsyncFunction();
expect(getDebugInfo(result)).toMatchInlineSnapshot(Object { "value": undefined, });
});
implementation
export async function someAsyncFunction() { return { value: [undefined], }; } -->
Actual Output
Object {
"value": [undefined],
}
-->
## The current behavior
The inline snapshot does not match the current output. The test expects `"value": undefined` but receives `"value": [ , ]`.
## The expected behavior
The test should pass and the snapshot should match the current output.
I ran the test with yarn test --testPathPattern=ReactFlightAsyncDebugInfo-test.js and the result was:
yarn run v1.22.22
$ node ./scripts/jest/jest-cli.js --testPathPattern=ReactFlightAsyncDebugInfo-test.js
$ NODE_ENV=development RELEASE_CHANNEL=experimental compactConsole=false node ./scripts/jest/jest.js --config ./scripts/jest/config.source.js --testPathPattern=ReactFlightAsyncDebugInfo-test.js
Running tests for default (experimental)...
PASS packages/react-server/src/__tests__/ReactFlightAsyncDebugInfo-test.js
ReactFlightAsyncDebugInfo
✓ can track async information when awaited (401 ms)
✓ adds a description to I/O (290 ms)
✓ can track async information when use()d (152 ms)
✓ cannot currently track the start of I/O when no native promise is used (133 ms)
✓ can ingores the start of I/O when immediately resolved non-native promise is awaited (153 ms)
✓ forwards debugInfo from awaited Promises (132 ms)
✓ forwards async debug info one environment to the next (160 ms)
✓ can track cached entries awaited in later components (151 ms)
✓ can track cached entries used in child position (136 ms)
✓ can track implicit returned promises that are blocked by previous data (133 ms)
✓ can track IO that is chained via then(async ...) (141 ms)
✓ can track IO that is not awaited in user space (151 ms)
✓ can track IO in third-party code (147 ms)
✓ can track async file reads (136 ms)
✓ can track a promise created fully outside first party code (132 ms)
Test Suites: 1 passed, 1 total
Tests: 15 passed, 15 total
Snapshots: 15 passed, 15 total
Time: 3.651 s, estimated 4 s
Ran all test suites matching /ReactFlightAsyncDebugInfo-test.js/i.
Done in 6.72s.
It proved that they seem to be working fine. From current state, the snapshot and runtime output appear aligned, so this issue may no longer be valid.
Note:- The tests exists within packages/react-server/src/__tests__/ not packages/react-server/src/tests/ which explains why your command failed or appears broken.
Which Node.js version are you using? Different versions of Node.js could change the snapshots.