Skip to content

fix(tests): make orphan audit + image-path checks cross-platform (Windows) - #76

Merged
Jazy1 merged 1 commit into
Orenda-Project:mainfrom
globetrotdev:fix/windows-test-path-separators
Jul 27, 2026
Merged

fix(tests): make orphan audit + image-path checks cross-platform (Windows)#76
Jazy1 merged 1 commit into
Orenda-Project:mainfrom
globetrotdev:fix/windows-test-path-separators

Conversation

@globetrotdev

Copy link
Copy Markdown
Contributor

Problem

Two test-harness assumptions hard-code the POSIX / separator, so npm test
fails on Windows even on a clean checkout (both pass on Linux CI):

  1. tests/setup/_audit-helpers/require-graph.jswalkJs builds paths with
    path.join() (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 (20) is
    wrongly reported as an orphan module.
  2. tests/whatsapp/send-image-from-url.test.jsexpect(pathArg).toContain('/')
    asserts a file path; Windows temp paths use \, so it fails although the
    code under test behaves correctly.

Fix

  • Match on path.sep instead of a hard-coded /, following the existing idiom
    in tests/setup/source-hygiene.test.js.
  • Assert /[\\/]/ instead of toContain('/').

Test-only; no production code touched.

Verification

npm test on Windows: 1320 passed, 1 skipped, 0 failed (was 2 failed).
Behaviour on Linux is unchanged.

…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
Jazy1 merged commit 4a856f6 into Orenda-Project:main Jul 27, 2026
5 checks passed
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.

2 participants