fix(tests): make orphan audit + image-path checks cross-platform (Windows) - #76
Merged
Jazy1 merged 1 commit intoJul 27, 2026
Conversation
…dows)
Two test-harness assumptions hard-coded the POSIX '/' separator and failed
on Windows (both pass on Linux CI):
- require-graph.js: walkJs yields path.join() output (native separators), but
the node_modules guard and the __mocks__/__tests__ exclusion tested for the
literal '/'. On Windows (paths use '\') every Jest __mocks__ file in the
audited dirs was wrongly flagged as an orphan module. Switched both checks
to path.sep, matching the existing idiom in tests/setup/source-hygiene.test.js.
- send-image-from-url.test.js: expect(pathArg).toContain('/') asserted a file
path; Windows temp paths use '\'. Match /[\\/]/ to accept either separator.
Test-only; no production code changed.
Verified: npm test on Windows -> 1320 passed, 1 skipped, 0 failed (was 2 failed);
behaviour on Linux unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Jazy1
approved these changes
Jul 27, 2026
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.
Problem
Two test-harness assumptions hard-code the POSIX
/separator, sonpm testfails on Windows even on a clean checkout (both pass on Linux CI):
tests/setup/_audit-helpers/require-graph.js—walkJsbuilds paths withpath.join()(native separators), but thenode_modulesguard and the__mocks__/__tests__exclusion tested for the literal/. On Windows(paths use
\) every Jest__mocks__file in the audited dirs (20) iswrongly reported as an orphan module.
tests/whatsapp/send-image-from-url.test.js—expect(pathArg).toContain('/')asserts a file path; Windows temp paths use
\, so it fails although thecode under test behaves correctly.
Fix
path.sepinstead of a hard-coded/, following the existing idiomin
tests/setup/source-hygiene.test.js./[\\/]/instead oftoContain('/').Test-only; no production code touched.
Verification
npm teston Windows: 1320 passed, 1 skipped, 0 failed (was 2 failed).Behaviour on Linux is unchanged.