Skip to content

Commit

Permalink
fix(repo): should ensure that unit tests are run correctly across pac…
Browse files Browse the repository at this point in the history
…kage managers (#22978)
  • Loading branch information
Coly010 committed Apr 26, 2024
1 parent d3454ed commit aa76007
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit aa76007

Please sign in to comment.