@nuxt/test-utils 3.22.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/config.d.mts +1 -5
- package/dist/config.mjs +41 -17
- package/dist/e2e.d.mts +3 -2
- package/dist/e2e.mjs +3 -3
- package/dist/experimental.mjs +1 -1
- package/dist/module.d.mts +2 -2
- package/dist/module.mjs +477 -37
- package/dist/playwright.d.mts +2 -1
- package/dist/playwright.mjs +5 -4
- package/dist/runtime/browser-entry.mjs +2 -5
- package/dist/runtime/entry.mjs +4 -3
- package/dist/runtime/shared/environment.mjs +12 -77
- package/dist/runtime/shared/h3-v1.d.ts +6 -0
- package/dist/runtime/shared/h3-v1.mjs +69 -0
- package/dist/runtime/shared/h3-v2.d.ts +6 -0
- package/dist/runtime/shared/h3-v2.mjs +35 -0
- package/dist/runtime/shared/h3.d.ts +3 -0
- package/dist/runtime/shared/h3.mjs +3 -0
- package/dist/runtime/shared/vue-wrapper-plugin.mjs +1 -1
- package/dist/runtime-utils/index.d.mts +3 -2
- package/dist/runtime-utils/index.mjs +49 -27
- package/dist/shared/{test-utils.ZByFDqps.d.mts → test-utils.BLyxqr96.d.mts} +5 -4
- package/dist/shared/{test-utils.C_clWQBc.mjs → test-utils.BsmyE2FA.mjs} +6 -4
- package/dist/shared/{test-utils.D2ZzXztg.mjs → test-utils.E_cAGA8l.mjs} +4 -4
- package/dist/vitest-environment.d.mts +18 -6
- package/dist/vitest-environment.mjs +125 -83
- package/dist/vitest-wrapper/cli.mjs +8 -2
- package/package.json +46 -40
package/README.md
CHANGED
package/dist/config.d.mts
CHANGED
|
@@ -46,6 +46,7 @@ interface NuxtEnvironmentOptions {
|
|
|
46
46
|
* @default 'happy-dom'
|
|
47
47
|
*/
|
|
48
48
|
domEnvironment?: 'happy-dom' | 'jsdom';
|
|
49
|
+
h3Version?: 1 | 2;
|
|
49
50
|
mock?: {
|
|
50
51
|
intersectionObserver?: boolean;
|
|
51
52
|
indexedDb?: boolean;
|
|
@@ -56,11 +57,6 @@ declare module 'vitest/node' {
|
|
|
56
57
|
nuxt?: NuxtEnvironmentOptions;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
declare module 'vitest' {
|
|
60
|
-
interface EnvironmentOptions {
|
|
61
|
-
nuxt?: NuxtEnvironmentOptions;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
60
|
|
|
65
61
|
export { defineVitestConfig, defineVitestProject, getVitestConfigFromNuxt };
|
|
66
62
|
export type { NuxtEnvironmentOptions };
|
package/dist/config.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { defineConfig } from 'vite';
|
|
3
3
|
import { setupDotenv } from 'c12';
|
|
4
|
-
import { defu } from 'defu';
|
|
4
|
+
import { createDefu, defu } from 'defu';
|
|
5
5
|
import { createResolver, findPath } from '@nuxt/kit';
|
|
6
|
+
import { resolveModulePath } from 'exsolve';
|
|
7
|
+
import { getPackageInfoSync } from 'local-pkg';
|
|
6
8
|
import { a as applyEnv, l as loadKit } from './shared/test-utils.BIY9XRkB.mjs';
|
|
7
9
|
import 'destr';
|
|
8
10
|
import 'scule';
|
|
9
11
|
import 'node:url';
|
|
10
|
-
import 'exsolve';
|
|
11
12
|
|
|
12
13
|
const PLUGIN_NAME = "nuxt:vitest:nuxt-environment-options";
|
|
13
14
|
const STUB_ID = "nuxt-vitest-environment-options";
|
|
@@ -94,6 +95,21 @@ async function getVitestConfigFromNuxt(options, loadNuxtOptions = {}) {
|
|
|
94
95
|
}
|
|
95
96
|
delete options.viteConfig.root;
|
|
96
97
|
options.viteConfig.plugins = (options.viteConfig.plugins || []).filter((p) => !p || !("name" in p) || !excludedPlugins.includes(p.name));
|
|
98
|
+
const nuxtServerIntegration = getPackageInfoSync("@nuxt/nitro-server", {
|
|
99
|
+
paths: [options.nuxt.options.appDir]
|
|
100
|
+
});
|
|
101
|
+
let nitroPath;
|
|
102
|
+
for (const nitroCandidate of [
|
|
103
|
+
...nuxtServerIntegration?.packageJson.dependencies?.nitro ? ["nitro", "nitro-nightly"] : ["nitropack", "nitropack-nightly"]
|
|
104
|
+
]) {
|
|
105
|
+
nitroPath = resolveModulePath(nitroCandidate, { from: nuxtServerIntegration?.rootPath || options.nuxt.options.appDir, try: true });
|
|
106
|
+
if (nitroPath) {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const h3Info = getPackageInfoSync("h3", {
|
|
111
|
+
paths: nitroPath ? [nitroPath] : options.nuxt.options.modulesDir
|
|
112
|
+
});
|
|
97
113
|
const resolver = createResolver(import.meta.url);
|
|
98
114
|
const resolvedConfig = defu(
|
|
99
115
|
// overrides
|
|
@@ -188,6 +204,7 @@ async function getVitestConfigFromNuxt(options, loadNuxtOptions = {}) {
|
|
|
188
204
|
environmentOptions: {
|
|
189
205
|
nuxt: {
|
|
190
206
|
rootId: options.nuxt.options.app.rootId || void 0,
|
|
207
|
+
h3Version: h3Info?.version?.startsWith("2.") ? 2 : 1,
|
|
191
208
|
mock: {
|
|
192
209
|
intersectionObserver: true,
|
|
193
210
|
indexedDb: false
|
|
@@ -224,25 +241,29 @@ function defineVitestConfig(config = {}) {
|
|
|
224
241
|
}
|
|
225
242
|
const defaultEnvironment = resolvedConfig.test.environment || "node";
|
|
226
243
|
if (defaultEnvironment !== "nuxt") {
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
244
|
+
const merge = createDefu((obj, key, value) => {
|
|
245
|
+
if (Array.isArray(value) && Array.isArray(obj[key])) {
|
|
246
|
+
obj[key] = [.../* @__PURE__ */ new Set([...value, ...obj[key]])];
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
const nuxtProject = merge({
|
|
251
|
+
...resolvedConfig,
|
|
234
252
|
test: {
|
|
253
|
+
...resolvedConfig.test,
|
|
235
254
|
name: "nuxt",
|
|
236
255
|
environment: "nuxt",
|
|
237
|
-
include: [
|
|
238
|
-
"**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
239
|
-
"{test,tests}/nuxt/**.*"
|
|
240
|
-
]
|
|
256
|
+
include: []
|
|
241
257
|
}
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
|
|
258
|
+
}, resolvedConfig);
|
|
259
|
+
nuxtProject.test.include = [
|
|
260
|
+
"**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
261
|
+
"{test,tests}/nuxt/**.*"
|
|
262
|
+
];
|
|
263
|
+
const defaultProject = merge({
|
|
264
|
+
...resolvedConfig,
|
|
245
265
|
test: {
|
|
266
|
+
...resolvedConfig.test,
|
|
246
267
|
name: defaultEnvironment,
|
|
247
268
|
environment: defaultEnvironment,
|
|
248
269
|
exclude: [
|
|
@@ -255,7 +276,10 @@ function defineVitestConfig(config = {}) {
|
|
|
255
276
|
"./{test,tests}/nuxt/**.*"
|
|
256
277
|
]
|
|
257
278
|
}
|
|
258
|
-
});
|
|
279
|
+
}, resolvedConfig);
|
|
280
|
+
resolvedConfig.test = {
|
|
281
|
+
projects: [nuxtProject, defaultProject]
|
|
282
|
+
};
|
|
259
283
|
}
|
|
260
284
|
return resolvedConfig;
|
|
261
285
|
});
|
package/dist/e2e.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { T as TestOptions, b as TestContext, a as TestHooks } from './shared/test-utils.
|
|
2
|
-
export { $ as $fetch, G as GotoOptions, N as NuxtPage, S as StartServerOptions,
|
|
1
|
+
import { T as TestOptions, b as TestContext, a as TestHooks } from './shared/test-utils.BLyxqr96.mjs';
|
|
2
|
+
export { $ as $fetch, G as GotoOptions, N as NuxtPage, S as StartServerOptions, c as TestRunner, d as createBrowser, e as createPage, f as fetch, g as getBrowser, s as startServer, h as stopServer, u as url, w as waitForHydration } from './shared/test-utils.BLyxqr96.mjs';
|
|
3
3
|
import { LogType } from 'consola';
|
|
4
4
|
import 'playwright-core';
|
|
5
5
|
import '@nuxt/schema';
|
|
6
6
|
import 'tinyexec';
|
|
7
|
+
import 'ofetch';
|
|
7
8
|
|
|
8
9
|
declare function createTestContext(options: Partial<TestOptions>): TestContext;
|
|
9
10
|
declare function useTestContext(): TestContext;
|
package/dist/e2e.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { b as buildFixture, c as createBrowser, a as createPage, d as createTest, g as getBrowser, l as loadFixture,
|
|
2
|
-
import { u as useTestContext } from './shared/test-utils.
|
|
3
|
-
export { $ as $fetch, c as createTestContext, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv, s as setTestContext, a as startServer, b as stopServer, d as url } from './shared/test-utils.
|
|
1
|
+
export { b as buildFixture, c as createBrowser, a as createPage, d as createTest, g as getBrowser, l as loadFixture, s as setup, e as setupMaps, w as waitForHydration } from './shared/test-utils.E_cAGA8l.mjs';
|
|
2
|
+
import { u as useTestContext } from './shared/test-utils.BsmyE2FA.mjs';
|
|
3
|
+
export { $ as $fetch, c as createTestContext, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv, s as setTestContext, a as startServer, b as stopServer, d as url } from './shared/test-utils.BsmyE2FA.mjs';
|
|
4
4
|
import { consola } from 'consola';
|
|
5
5
|
import { resolve } from 'pathe';
|
|
6
6
|
import { distDir } from '#dirs';
|
package/dist/experimental.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'pathe';
|
|
2
2
|
import { stringifyQuery } from 'ufo';
|
|
3
|
-
import { $ as $fetch, u as useTestContext } from './shared/test-utils.
|
|
3
|
+
import { $ as $fetch, u as useTestContext } from './shared/test-utils.BsmyE2FA.mjs';
|
|
4
4
|
import 'tinyexec';
|
|
5
5
|
import 'get-port-please';
|
|
6
6
|
import 'ofetch';
|
package/dist/module.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import {
|
|
2
|
+
import { TestUserConfig } from 'vitest/config';
|
|
3
3
|
|
|
4
4
|
interface NuxtVitestOptions {
|
|
5
5
|
startOnBoot?: boolean;
|
|
6
6
|
logToConsole?: boolean;
|
|
7
|
-
vitestConfig?:
|
|
7
|
+
vitestConfig?: TestUserConfig;
|
|
8
8
|
}
|
|
9
9
|
declare const _default: _nuxt_schema.NuxtModule<NuxtVitestOptions, NuxtVitestOptions, false>;
|
|
10
10
|
|