Skip to content

Fix Windows-incompatible Jest tests - #1937

Merged
robhogan merged 1 commit into
mainfrom
pr1937
Sep 29, 2026
Merged

robhogan merged 1 commit into
mainfrom
pr1937

Conversation

@robhogan

@robhogan robhogan commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

scripts/jestFilter.js skipped 25 test suites on Windows. Most of them failed because of posix assumptions in the tests rather than in Metro, so this fixes the tests and removes them from the skip list to run in Windows CI.

The tests still assert the same things, but filesystem paths are written as posix and passed through the existing p() helpers (posixToSystemPath, createPathNormalizer), so on Windows they're realistic C:\... paths. Client-facing values - URLs, httpServerLocation, sourceURLs, specifiers, package.json keys - are still asserted with forward slashes on every platform.

Suites parameterised over posix and win32 now mock node:path with path.posix for the posix half, rather than the host's path (which is path.win32 on Windows). metro-resolver's getPackageForModule test helper also looped forever on Windows and hung three suites, because path.win32.parse('/root').root is / but dirname returns \.

Still skipped on Windows:

Changelog: Internal

Test plan:
Windows CI on this PR - every suite passes except the three still skipped, whose Windows failures are exactly the bugs above.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 17, 2026
@robhogan
robhogan force-pushed the pr1937 branch 2 times, most recently from a566848 to 7138ab8 Compare September 17, 2026 11:47
@robhogan robhogan changed the title Run all Jest tests on Windows Fix Windows-incompatible Jest tests Sep 17, 2026
@robhogan
robhogan added this pull request to stack #1940 September 17, 2026 11:47
@robhogan
robhogan marked this pull request as ready for review September 17, 2026 11:49
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 17, 2026
@meta-codesync

meta-codesync Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@vzaidman has imported this pull request. If you are a Meta employee, you can view this in D120534260.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

馃煝 Approval recommended

No unresolved blocking issues are identified.

Review effort: Lite
Findings: None

What changed in this PR

Updates Metro鈥檚 Jest tests for Windows compatibility by removing POSIX-only assumptions and obsolete Windows skips.

Changes:

  • Normalizes filesystem paths across affected test suites.
  • Corrects platform-specific mocks and resolver traversal.
  • Retains only documented Windows skips.
File Description
scripts/鈥媕estFilter.js Updates the Windows skip list.
packages/鈥媘etro/鈥媠rc/鈥婼erver/鈥媉_tests__/鈥婼erver-test.js Normalizes filesystem paths.
packages/鈥媘etro/鈥媠rc/鈥媙ode-haste/鈥媗ib/鈥媉_tests__/鈥婣ssetPaths-test.js Uses native path inputs.
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥婼erializers/鈥媓elpers/鈥媉_tests__/鈥媕s-test.js Makes module paths portable.
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媉_tests__/鈥媟esolver-test.js Uses POSIX path mocks.
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媉_tests__/鈥婫raph-test.js Normalizes graph paths.
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媉_tests__/鈥婦eltaCalculator-test.js Corrects POSIX mock behavior.
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媉_tests__/鈥媌uildSubgraph-test.js Normalizes subgraph paths.
packages/鈥媘etro/鈥媠rc/鈥媉_tests__/鈥婬mrServer-test.js Normalizes module paths.
packages/鈥媘etro/鈥媠rc/鈥媉_tests__/鈥婣ssets-test.js Uses platform-aware filesystem paths.
packages/鈥媘etro-transform-worker/鈥媠rc/鈥媉_tests__/鈥媔ndex-test.js Removes incompatible transformer filesystem setup.
packages/鈥媘etro-symbolicate/鈥媠rc/鈥媉_tests__/鈥媠ymbolicate-test.js Normalizes absolute-path snapshots.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媢tils.js Fixes Windows package traversal.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媠ymlinks-test.js Normalizes symlink paths.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媝latform-extensions-test.js Normalizes resolver paths.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媝ackage-exports-test.js Makes export tests portable.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媔ndex-test.js Makes resolver expectations portable.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媌rowser-spec-test.js Normalizes browser resolution paths.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媋ssets-test.js Normalizes asset paths.
packages/鈥媘etro-resolver/鈥媠rc/鈥媉_tests__/鈥媉_snapshots__/鈥媔ndex-test.js.snap Removes the replaced path-dependent snapshot.
packages/鈥媘etro-file-map/鈥媠rc/鈥媍rawlers/鈥媉_tests__/鈥媙ode-test.js Tests both path platforms.
packages/鈥媘etro-file-map/鈥媠rc/鈥媉_tests__/鈥媔ndex-test.js Normalizes file-map paths and messages.
packages/鈥媌uck-worker-tool/鈥媠rc/鈥媉_tests__/鈥媤orker-test.js Uses POSIX paths for the mocked filesystem.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@robhogan

Copy link
Copy Markdown
Collaborator Author

@vzaidman - thanks for the stamp but since it's been imported I can't merge it from here - D120534260 needs to land.

@vzaidman

Copy link
Copy Markdown
Contributor

I'll land it

@vzaidman

Copy link
Copy Markdown
Contributor

@robhogan please rebase and land it. I unlinked it from the imported PR.

@robhogan
robhogan force-pushed the pr1937 branch 2 times, most recently from 5c51121 to 2d1913b Compare September 29, 2026 16:04
Summary:
`scripts/jestFilter.js` skipped 30 test suites on Windows. Most were failing because of posix assumptions in the tests themselves, not Metro. This fixes those tests and removes them from the skip list, so they run in Windows CI.

The fixes remove posix assumptions without weakening what's asserted:
- Filesystem paths in inputs and expectations are written as posix and made portable with the existing `p()` helpers (`posixToSystemPath`, `createPathNormalizer`), so tests use realistic `C:\...` paths on Windows.
- Client-facing values - URLs, `httpServerLocation`, `sourceURL`s, specifiers, package.json keys - stay asserted with forward slashes on every platform.
- Suites parameterised over `posix`/`win32` now mock `node:path` with `path.posix` for the posix half, rather than the host's `path`, which on Windows is `path.win32`.
- `metro-resolver`'s `getPackageForModule` test helper looped forever on Windows (`path.win32.parse('/root').root` is `/` but `dirname` returns `\`), hanging three suites.
- Some inline and file snapshots embedding absolute paths are replaced by exact assertions built with `p()`.

Still skipped on Windows:
- `api-snapshots-sync-test.js` - `flow-api-translator` emits `os.EOL` line endings in generated comments. API snapshots are only meaningfully generated on posix.
- `js-test.js` and `symbolicate-test.js` - these expose real Windows bugs, fixed and unskipped in the next commits in this stack.

Changelog: [Internal]

Test Plan:
Windows CI on this PR: all suites pass except the three still skipped, whose failures on Windows are exactly the product bugs described above.

```
yarn jest
Test Suites: 148 passed, 148 total
yarn flow check
yarn lint
```
@robhogan
robhogan merged commit 13604e0 into main Sep 29, 2026
15 checks passed
robhogan added a commit that referenced this pull request Sep 29, 2026
#1937 runs Server-test and the metro-transform-worker tests on Windows against a platform-aware `metro-memory-fs`, so the asset URL tests added here, written against POSIX paths, failed there after merging main. They now build their paths with `posixToSystemPath`, as the rest of those files do, and the metro-transform-worker test gets the same platform-aware in-memory filesystem as `Assets-test`. `metro-resolver` becomes a devDependency of `metro-transform-worker` for the helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants