Skip to content

fix(jest): use forward slashes in test file names on Windows - #240

Merged
V3RON merged 1 commit into
mainfrom
fix/issue-216-windows-test-file-separators
Oct 20, 2026
Merged

V3RON merged 1 commit into
mainfrom
fix/issue-216-windows-test-file-separators

Conversation

@V3RON

@V3RON V3RON commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What is this?

On Windows, Jest test and setup file names reached the device with backslash separators (for example src\__tests__\normal\smoke.harness.ts) instead of forward slashes. Harness now sends these names with forward slashes on every host, so tests that assert on context.task.file.name see the same value on Windows as on macOS and Linux. This fixes #216.

How does it work?

The Jest runner builds each test file name and setup file name from path.relative, which uses the host's separator. A small helper in @react-native-harness/jest now converts that result to forward slashes. The helper is applied to the test path, the setup files, and the per-file names used by file hooks, run hooks, and diagnostics.

Why is this useful?

Test authors on Windows can rely on stable file names in their assertions and in plugin hooks, and Metro bundle URLs for test and setup files are built from consistent paths. Behavior on macOS and Linux does not change.

Relative test and setup file paths were built with path.relative, which uses backslashes on Windows. These names are sent to the device, used in Metro bundle URLs, and reported to plugin hooks, so normalize them to forward slashes.

Fixes #216
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-native-harness Ready Ready Preview Oct 20, 2026 6:44am UTC

Request Review

@V3RON
V3RON merged commit b0e4eda into main Oct 20, 2026
6 checks passed
@V3RON
V3RON deleted the fix/issue-216-windows-test-file-separators branch October 20, 2026 16:15

This branch was successfully deployed

1 active deployment
Preview — 1f8383af Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On a Windows host, a test's file name reaches the device with backslashes

1 participant