Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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')
);
});

Expand Down Expand Up @@ -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')
);
});

Expand All @@ -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')
);
});
});
Expand Down