From d99e713970db46db866903b5c446904d3f3c1a75 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 2 Feb 2024 11:51:12 +0100 Subject: [PATCH] e2e-test: override yarn.lock seed to use the one in repo Signed-off-by: Patrik Oldsberg --- packages/e2e-test/src/commands/run.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index a9256695ec..cadd7b878d 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -263,6 +263,9 @@ async function createApp( const appDir = resolvePath(rootDir, appName); + print('Overriding yarn.lock with seed file from the create-app package'); + overrideYarnLockSeed(appDir); + print('Rewriting module resolutions of app to use workspace packages'); await overrideModuleResolutions(appDir, workspaceDir); @@ -305,6 +308,22 @@ async function createApp( } } +/** + * Overrides the downloaded yarn.lock file with the seed file packages/create-app/seed-yarn.lock + * This ensures that the E2E tests use the same seed file as users would receive when creating a new app + */ +async function overrideYarnLockSeed(appDir: string) { + const content = await fs.readFile( + paths.resolveOwnRoot('packages/create-app/seed-yarn.lock'), + 'utf8', + ); + const trimmedContent = content + .split('\n') + .filter(l => !l.startsWith('//')) + .join('\n'); + await fs.writeFile(resolvePath(appDir, 'yarn.lock'), trimmedContent, 'utf8'); +} + /** * This points dependency resolutions into the workspace for each package that is present there */