N
Nuxt6mo ago
Zampa

Adding `/pages/index.vue` breaks e2e testing

Reproduction: https://stackblitz.com/edit/github-gu1sj1-xq3xf8?file=tests%2Fe2e%2Fbasic.e2e.test.ts A minimal repo with just vitest and @nuxt/test-utils, an app.vue, and a pages/index.vue fails with error:
❯ npm run test

> test
> vitest

Running with compatibility version `4`

DEV v1.6.0 /home/projects/github-gu1sj1-xq3xf8/app

❯ ../tests/e2e/basic.e2e.test.ts (1)
basic (1)
⠹ [ beforeAll ]
· contains Welcome to Nuxt! string

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

FAIL ../tests/e2e/basic.e2e.test.ts > basic
Error: Cannot find any nuxt version from ./app
❯ Module.loadNuxt ../node_modules/@nuxt/kit/dist/index.mjs:2729:11
❯ loadFixture ../node_modules/@nuxt/test-utils/dist/shared/test-utils.C7cWLW4C.mjs:102:14
100| });
101| const buildDir = ctx.nuxt.options.buildDir;
102| if (!existsSync(buildDir)) {
| ^
103| await promises.mkdir(buildDir, { recursive: true });
104| ctx.teardown = ctx.teardown || [];
❯ setup2 ../node_modules/@nuxt/test-utils/dist/shared/test-utils.C7cWLW4C.mjs:178:7

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files 1 failed (1)
Tests (1)
Start at 09:54:14
Duration 4.84s (transform 445ms, setup 45ms, collect 2.14s, tests 5ms, environment 0ms, prepare 807ms)
❯ npm run test

> test
> vitest

Running with compatibility version `4`

DEV v1.6.0 /home/projects/github-gu1sj1-xq3xf8/app

❯ ../tests/e2e/basic.e2e.test.ts (1)
basic (1)
⠹ [ beforeAll ]
· contains Welcome to Nuxt! string

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

FAIL ../tests/e2e/basic.e2e.test.ts > basic
Error: Cannot find any nuxt version from ./app
❯ Module.loadNuxt ../node_modules/@nuxt/kit/dist/index.mjs:2729:11
❯ loadFixture ../node_modules/@nuxt/test-utils/dist/shared/test-utils.C7cWLW4C.mjs:102:14
100| });
101| const buildDir = ctx.nuxt.options.buildDir;
102| if (!existsSync(buildDir)) {
| ^
103| await promises.mkdir(buildDir, { recursive: true });
104| ctx.teardown = ctx.teardown || [];
❯ setup2 ../node_modules/@nuxt/test-utils/dist/shared/test-utils.C7cWLW4C.mjs:178:7

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files 1 failed (1)
Tests (1)
Start at 09:54:14
Duration 4.84s (transform 445ms, setup 45ms, collect 2.14s, tests 5ms, environment 0ms, prepare 807ms)
Nathan Chase
StackBlitz
Nuxt - Starter (forked) - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
1 Reply
Zampa
ZampaOP6mo ago
Oh, I found the culprit. The path of rootDir has to be an absolute path, not a relative path.
// fails
await setup({
rootDir: './app',
});
// fails
await setup({
rootDir: './app',
});
// works
await setup({
rootDir: './../app',
});
// works
await setup({
rootDir: './../app',
});
// also works
await setup({
rootDir: '~/app',
});
// also works
await setup({
rootDir: '~/app',
});
Want results from more Discord servers?
Add your server