Skip to content

Commit 58db060

Browse files
authored
chore: handle e2e fixtures with node_modules (#352)
1 parent 79974d1 commit 58db060

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/netlify-deploy.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,30 @@ export class NextDeployInstance extends NextInstance {
2929
// create the test site
3030
await super.createTestDir({ parentSpan, skipInstall: true })
3131

32+
// If the test fixture has node modules we need to move them aside then merge them in after
33+
34+
const nodeModules = path.join(this.testDir, 'node_modules')
35+
const nodeModulesBak = `${nodeModules}.bak`
36+
37+
if (fs.existsSync(nodeModules)) {
38+
await fs.rename(nodeModules, nodeModulesBak)
39+
}
40+
3241
// install dependencies
3342
await execa('npm', ['i'], {
3443
cwd: this.testDir,
3544
stdio: 'inherit',
3645
})
3746

47+
if (fs.existsSync(nodeModulesBak)) {
48+
// move the contents of the fixture node_modules into the installed modules
49+
for (const file of await fs.readdir(nodeModulesBak)) {
50+
await fs.move(path.join(nodeModulesBak, file), path.join(nodeModules, file), {
51+
overwrite: true,
52+
})
53+
}
54+
}
55+
3856
// use next runtime package installed by the test runner
3957
if (!fs.existsSync(path.join(this.testDir, 'netlify.toml'))) {
4058
const toml = /* toml */ `

0 commit comments

Comments
 (0)