Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[heft-jest] Fix node-modules-symlink-resolver #5013

Merged
merged 1 commit into from
Nov 23, 2024
Merged
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
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-jest-plugin",
"comment": "Fix a bug in `jest-node-modules-symlink-resolver` with respect to evaluating paths that don't exist. Expected behavior in that situation is to return the input path.",
"type": "patch"
}
],
"packageName": "@rushstack/heft-jest-plugin"
}
7 changes: 1 addition & 6 deletions heft-plugins/heft-jest-plugin/src/JestRealPathPatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as path from 'node:path';
import { RealNodeModulePathResolver } from '@rushstack/node-core-library/lib/RealNodeModulePath';

const jestResolvePackageFolder: string = path.dirname(require.resolve('jest-resolve/package.json'));
const jestResolveFileWalkersPath: string = path.resolve(jestResolvePackageFolder, './build/fileWalkers.js');

const jestUtilPackageFolder: string = path.dirname(
require.resolve('jest-util/package.json', { paths: [jestResolvePackageFolder] })
Expand All @@ -14,11 +13,6 @@ const jestUtilTryRealpathPath: string = path.resolve(jestUtilPackageFolder, './b

const { realNodeModulePath }: RealNodeModulePathResolver = new RealNodeModulePathResolver();

const fileWalkersModule: {
realpathSync: (filePath: string) => string;
} = require(jestResolveFileWalkersPath);
fileWalkersModule.realpathSync = realNodeModulePath;

const tryRealpathModule: {
default: (filePath: string) => string;
} = require(jestUtilTryRealpathPath);
Expand All @@ -28,6 +22,7 @@ tryRealpathModule.default = (input: string): string => {
} catch (error) {
// Not using the helper from FileSystem here because this code loads in every Jest worker process
// and FileSystem has a lot of extra dependencies
// These error codes cloned from the logic in jest-util's tryRealpath.js
if (error.code !== 'ENOENT' && error.code !== 'EISDIR') {
throw error;
}
Expand Down
Loading