Skip to content

Commit 56dbfe7

Browse files
test: make path assertions platform-agnostic so the suite passes on Windows (#1450)
Co-authored-by: Daniel Williams <me@dannyhw.com>
1 parent ed1003f commit 56dbfe7

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎packages/repack/src/commands/common/__tests__/resolveProjectPath.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import path from 'node:path';
12
import { resolveProjectPath } from '../resolveProjectPath.js';
23

34
describe('resolveProjectPath', () => {
5+
// Cases use POSIX literals; `path.resolve` makes them platform-native.
6+
// The root must be resolved too: on Windows a drive-less root that walks up
7+
// to "/" collapses to "\\", which is then parsed as a UNC share.
48
const expectResolved = (
59
input: string,
610
expected: string,
711
root = '/project/root'
812
) => {
9-
expect(resolveProjectPath(input, root)).toBe(expected);
13+
expect(resolveProjectPath(input, path.resolve(root))).toBe(
14+
path.resolve(expected)
15+
);
1016
};
1117

1218
it('should resolve [projectRoot] prefix correctly', () => {

‎packages/repack/src/plugins/__tests__/HermesBytecodePlugin.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'node:fs';
22
import os from 'node:os';
3+
import path from 'node:path';
34
import { type Compiler, ModuleFilenameHelpers } from '@rspack/core';
45
import execa from 'execa';
56
import { HermesBytecodePlugin } from '../HermesBytecodePlugin/index.js';
@@ -108,7 +109,7 @@ describe('HermesBytecodePlugin', () => {
108109

109110
expect(execaNodeMock).toHaveBeenCalledTimes(1);
110111
expect(execaNodeMock.mock.calls[0][0]).toEqual(
111-
'path/to/react-native/scripts/compose-source-maps.js'
112+
path.normalize('path/to/react-native/scripts/compose-source-maps.js')
112113
);
113114
});
114115

@@ -156,7 +157,7 @@ describe('HermesBytecodePlugin', () => {
156157
const hermesPath = getHermesCLIPath(reactNativePath);
157158

158159
expect(hermesPath).toBe(
159-
'path/to/hermes-compiler/hermesc/osx-bin/hermesc'
160+
path.normalize('path/to/hermes-compiler/hermesc/osx-bin/hermesc')
160161
);
161162
});
162163

@@ -167,7 +168,7 @@ describe('HermesBytecodePlugin', () => {
167168
const hermesPath = getHermesCLIPath(reactNativePath);
168169

169170
expect(hermesPath).toBe(
170-
'path/to/react-native/sdks/hermesc/osx-bin/hermesc'
171+
path.normalize('path/to/react-native/sdks/hermesc/osx-bin/hermesc')
171172
);
172173
});
173174
});

0 commit comments

Comments
 (0)