N
Nuxt6mo ago
Zampa

Correct setup config for Test Utils

Reproduction: https://stackblitz.com/edit/github-gu1sj1?file=tests%2Fbasic.e2e.test.ts Issue filed: https://github.com/nuxt/test-utils/issues/893 I can't seem to utilize the alternative nuxt.config location with @nuxt/test-utils. If I have my nuxt.config as ./.config/nuxt.ts, e2e tests will always fail with Error: Invalid nuxt app. (Please explicitly set 'options.rootDir' pointing to a valid nuxt app). This is my test:
// ./tests/basic.e2e.test.ts
import { $fetch, setup } from '@nuxt/test-utils/e2e';
import { describe, expect, it } from 'vitest';

describe('basic', async () => {
await setup({
rootDir: './app',
configFile: '/.config/nuxt.ts',
});

it('contains Welcome to Nuxt! string', async () => {
const html = await $fetch('/');
expect(html).toContain('Welcome to Nuxt!');
});
});
// ./tests/basic.e2e.test.ts
import { $fetch, setup } from '@nuxt/test-utils/e2e';
import { describe, expect, it } from 'vitest';

describe('basic', async () => {
await setup({
rootDir: './app',
configFile: '/.config/nuxt.ts',
});

it('contains Welcome to Nuxt! string', async () => {
const html = await $fetch('/');
expect(html).toContain('Welcome to Nuxt!');
});
});
and my nuxt.config:
// ./.config/nuxt.ts
export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
future: {
compatibilityVersion: 4,
},
modules: ['@nuxt/test-utils/module'],
});
// ./.config/nuxt.ts
export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
future: {
compatibilityVersion: 4,
},
modules: ['@nuxt/test-utils/module'],
});
If I move and rename nuxt.config back to the root, it works. I'm not sure if this is a limitation or expectation of test-utils, or the config file name/location that isn't being honored by the configFile setting, or what.
Nathan Chase
StackBlitz
Nuxt - Starter - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
GitHub
e2e tests fail with Nuxt 4 config settings · Issue #893 · nuxt/test...
Environment Reproduction: https://stackblitz.com/edit/github-gu1sj1?file=tests%2Fbasic.e2e.test.ts I can't seem to utilize the alternative nuxt.config location with @nuxt/test-utils. If I have ...
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server