Repository navigation
fix(jest): use forward slashes in test file names on Windows - #240
Merged
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 oncontext.task.file.namesee 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/jestnow 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.