Skip to content

Commit e35dd95

Browse files
committed
test: give each dev fixture its own vite cache
1 parent 99c0bb8 commit e35dd95

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎packages/nuxt-cli/test/utils/index.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{cp,rm,symlink}from'node:fs/promises'
1+
import{cp,mkdir,readdir,rm,symlink}from'node:fs/promises'
22
import{join,sep}from'node:path'
33
import{fileURLToPath}from'node:url'
44
import{isCI}from'std-env'
@@ -28,6 +28,10 @@ export async function fetchWithPolling(url: string, options: RequestInit = {}, m
2828
* The dev e2e specs each wipe `.nuxt` and take the dev lock inside their
2929
* fixture, so pointing more than one of them at `fixtures/dev` makes them race
3030
* whenever vitest runs the files in parallel.
31+
*
32+
* Installed packages are linked in one by one rather than by symlinking
33+
* `node_modules` wholesale, so that the caches tooling writes underneath it
34+
* (`node_modules/.cache/vite`) belong to a single spec.
3135
*/
3236
exportasyncfunctioncreateDevFixture(name: string): Promise<string>{
3337
constsource=fileURLToPath(newURL('../fixtures/dev',import.meta.url))
@@ -38,7 +42,15 @@ export async function createDevFixture(name: string): Promise<string> {
3842
recursive: true,
3943
filter: entry=>!entry.includes('node_modules')&&!entry.includes(`${sep}.nuxt`),
4044
})
41-
awaitsymlink(join(source,'node_modules'),join(target,'node_modules'),'junction')
45+
constsourceModules=join(source,'node_modules')
46+
consttargetModules=join(target,'node_modules')
47+
awaitmkdir(targetModules,{recursive: true})
48+
for(constentryofawaitreaddir(sourceModules)){
49+
if(entry==='.cache'||entry==='.vite'){
50+
continue
51+
}
52+
awaitsymlink(join(sourceModules,entry),join(targetModules,entry),'junction')
53+
}
4254

4355
returntarget
4456
}

0 commit comments

Comments
 (0)