diff --git a/packages/repack/src/commands/common/__tests__/resolveProjectPath.test.ts b/packages/repack/src/commands/common/__tests__/resolveProjectPath.test.ts index 89d2e06c2..32e884ef7 100644 --- a/packages/repack/src/commands/common/__tests__/resolveProjectPath.test.ts +++ b/packages/repack/src/commands/common/__tests__/resolveProjectPath.test.ts @@ -1,12 +1,22 @@ +import path from 'node:path'; import { resolveProjectPath } from '../resolveProjectPath.js'; describe('resolveProjectPath', () => { + // The cases below are written with POSIX literals for readability. + // `resolveProjectPath` returns an absolute, platform-native path, so both the + // root and the expectation are run through `path.resolve` to give them a + // drive letter on Windows. Both calls are no-ops on POSIX. + // Resolving the root matters: without a drive, up-level navigation that + // reaches the root collapses to a bare "\\", which Windows then reads as the + // start of a UNC share rather than a local path. const expectResolved = ( input: string, expected: string, root = '/project/root' ) => { - expect(resolveProjectPath(input, root)).toBe(expected); + expect(resolveProjectPath(input, path.resolve(root))).toBe( + path.resolve(expected) + ); }; it('should resolve [projectRoot] prefix correctly', () => { diff --git a/packages/repack/src/plugins/__tests__/HermesBytecodePlugin.test.ts b/packages/repack/src/plugins/__tests__/HermesBytecodePlugin.test.ts index f93c32447..cf616df91 100644 --- a/packages/repack/src/plugins/__tests__/HermesBytecodePlugin.test.ts +++ b/packages/repack/src/plugins/__tests__/HermesBytecodePlugin.test.ts @@ -1,5 +1,6 @@ import fs from 'node:fs'; import os from 'node:os'; +import path from 'node:path'; import { type Compiler, ModuleFilenameHelpers } from '@rspack/core'; import execa from 'execa'; import { HermesBytecodePlugin } from '../HermesBytecodePlugin/index.js'; @@ -108,7 +109,7 @@ describe('HermesBytecodePlugin', () => { expect(execaNodeMock).toHaveBeenCalledTimes(1); expect(execaNodeMock.mock.calls[0][0]).toEqual( - 'path/to/react-native/scripts/compose-source-maps.js' + path.join('path/to/react-native/scripts/compose-source-maps.js') ); }); @@ -156,7 +157,7 @@ describe('HermesBytecodePlugin', () => { const hermesPath = getHermesCLIPath(reactNativePath); expect(hermesPath).toBe( - 'path/to/hermes-compiler/hermesc/osx-bin/hermesc' + path.join('path/to/hermes-compiler/hermesc/osx-bin/hermesc') ); }); @@ -167,7 +168,7 @@ describe('HermesBytecodePlugin', () => { const hermesPath = getHermesCLIPath(reactNativePath); expect(hermesPath).toBe( - 'path/to/react-native/sdks/hermesc/osx-bin/hermesc' + path.join('path/to/react-native/sdks/hermesc/osx-bin/hermesc') ); }); });