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

fix(repo): should ensure that unit tests are run correctly across package managers #22978

Merged
merged 1 commit into from
Apr 26, 2024
Merged
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,5 +1,6 @@
import { FsTree } from '../tree';
import type { Tree } from '../tree';
import { workspaceRoot } from '../../utils/workspace-root';

/**
* Creates a host for testing.
Expand All @@ -8,6 +9,12 @@ export function createTreeWithEmptyWorkspace(
opts = {} as { layout?: 'apps-libs' }
): Tree {
const tree = new FsTree('/virtual', false);
// Our unit tests are all written as though they are at the root of a workspace
// However, when they are run in a subdirectory of the workspaceRoot,
// the relative path between workspaceRoot and the directory the tests are run
// is prepended to the paths created in the virtual tree.
// Setting this envVar to workspaceRoot prevents this behaviour
process.env.INIT_CWD = workspaceRoot;
return addCommonFiles(tree, opts.layout === 'apps-libs');
}

Expand Down