@nuxt/test-utils-nightly 4.0.0-1701501480.7490334 → 4.0.0-1702810232.fba662c
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 +1 -1
- package/dist/config.mjs +32 -20
- package/dist/{index.d.mts → e2e.d.mts} +5 -0
- package/dist/{index.d.ts → e2e.d.ts} +5 -0
- package/dist/{index.mjs → e2e.mjs} +11 -5
- package/dist/module.mjs +13 -11
- package/dist/runtime/entry.mjs +1 -0
- package/dist/runtime/global-setup.mjs +1 -1
- package/dist/{runtime-utils.d.ts → runtime-utils/index.d.mts} +5 -5
- package/dist/{runtime-utils.d.mts → runtime-utils/index.d.ts} +5 -5
- package/dist/{runtime-utils.mjs → runtime-utils/index.mjs} +26 -15
- package/e2e.d.ts +1 -0
- package/package.json +26 -22
- package/runtime.d.ts +1 -0
- package/runtime-utils.d.ts +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
Nuxt offers first-class support for e2e and unit testing of your Nuxt applications.
|
|
7
|
+
Nuxt offers first-class support for e2e and unit testing of your Nuxt applications.
|
|
8
8
|
|
|
9
9
|
Nuxt Test Utils is currently powering [the tests we use on Nuxt itself](https://github.com/nuxt/nuxt/tree/main/test), as well as tests used throughout the module ecosystem.
|
|
10
10
|
|
package/dist/config.mjs
CHANGED
|
@@ -18,7 +18,7 @@ async function startNuxtAndGetViteConfig(rootDir = process.cwd(), overrides) {
|
|
|
18
18
|
});
|
|
19
19
|
if (!nuxt.options._installedModules.find((i) => i?.meta?.name === "@nuxt/test-utils")) {
|
|
20
20
|
throw new Error(
|
|
21
|
-
"Failed to load nuxt-
|
|
21
|
+
"Failed to load `@nuxt/test-utils/module`. You may need to add it to your nuxt.config."
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -36,8 +36,11 @@ async function startNuxtAndGetViteConfig(rootDir = process.cwd(), overrides) {
|
|
|
36
36
|
}).finally(() => nuxt.close());
|
|
37
37
|
return promise;
|
|
38
38
|
}
|
|
39
|
+
const excludedPlugins = [
|
|
40
|
+
"nuxt:import-protection",
|
|
41
|
+
"vite-plugin-checker"
|
|
42
|
+
];
|
|
39
43
|
async function getVitestConfigFromNuxt(options, overrides) {
|
|
40
|
-
var _a;
|
|
41
44
|
const { rootDir = process.cwd(), ..._overrides } = overrides || {};
|
|
42
45
|
if (!options) {
|
|
43
46
|
options = await startNuxtAndGetViteConfig(rootDir, {
|
|
@@ -45,10 +48,7 @@ async function getVitestConfigFromNuxt(options, overrides) {
|
|
|
45
48
|
..._overrides
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
options.viteConfig.plugins = options.viteConfig.plugins?.filter(
|
|
50
|
-
(p) => p?.name !== "nuxt:import-protection"
|
|
51
|
-
);
|
|
51
|
+
options.viteConfig.plugins = (options.viteConfig.plugins || []).filter((p) => !excludedPlugins.includes(p?.name));
|
|
52
52
|
const resolvedConfig = defu(
|
|
53
53
|
// overrides
|
|
54
54
|
{
|
|
@@ -69,20 +69,29 @@ async function getVitestConfigFromNuxt(options, overrides) {
|
|
|
69
69
|
["**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}", "nuxt"],
|
|
70
70
|
["{test,tests}/nuxt/**.*", "nuxt"]
|
|
71
71
|
],
|
|
72
|
+
server: {
|
|
73
|
+
deps: {
|
|
74
|
+
inline: [
|
|
75
|
+
// vite-node defaults
|
|
76
|
+
/\/node_modules\/(.*\/)?(nuxt|nuxt3|nuxt-nightly)\//,
|
|
77
|
+
/^#/,
|
|
78
|
+
// additional deps
|
|
79
|
+
"@nuxt/test-utils",
|
|
80
|
+
"@nuxt/test-utils-nightly",
|
|
81
|
+
"@nuxt/test-utils-edge",
|
|
82
|
+
"vitest-environment-nuxt",
|
|
83
|
+
...options.nuxt.options.build.transpile.filter(
|
|
84
|
+
(r) => typeof r === "string" || r instanceof RegExp
|
|
85
|
+
)
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
72
89
|
deps: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"@nuxt/test-utils",
|
|
79
|
-
"@nuxt/test-utils-nightly",
|
|
80
|
-
"@nuxt/test-utils-edge",
|
|
81
|
-
"vitest-environment-nuxt",
|
|
82
|
-
...options.nuxt.options.build.transpile.filter(
|
|
83
|
-
(r) => typeof r === "string" || r instanceof RegExp
|
|
84
|
-
)
|
|
85
|
-
]
|
|
90
|
+
optimizer: {
|
|
91
|
+
web: {
|
|
92
|
+
enabled: false
|
|
93
|
+
}
|
|
94
|
+
}
|
|
86
95
|
}
|
|
87
96
|
}
|
|
88
97
|
},
|
|
@@ -134,9 +143,12 @@ function defineVitestConfig(config = {}) {
|
|
|
134
143
|
return config;
|
|
135
144
|
const overrides = config.test?.environmentOptions?.nuxt?.overrides || {};
|
|
136
145
|
overrides.rootDir = config.test?.environmentOptions?.nuxt?.rootDir;
|
|
146
|
+
if (config.test?.setupFiles && !Array.isArray(config.test.setupFiles)) {
|
|
147
|
+
config.test.setupFiles = [config.test.setupFiles].filter(Boolean);
|
|
148
|
+
}
|
|
137
149
|
return defu(
|
|
138
150
|
config,
|
|
139
|
-
await getVitestConfigFromNuxt(void 0, overrides)
|
|
151
|
+
await getVitestConfigFromNuxt(void 0, structuredClone(overrides))
|
|
140
152
|
);
|
|
141
153
|
});
|
|
142
154
|
}
|
|
@@ -37,6 +37,11 @@ interface TestContext {
|
|
|
37
37
|
url?: string;
|
|
38
38
|
serverProcess?: ExecaChildProcess;
|
|
39
39
|
mockFn?: Function;
|
|
40
|
+
/**
|
|
41
|
+
* Functions to run on the vitest `afterAll` hook.
|
|
42
|
+
* Useful for removing anything created during the test.
|
|
43
|
+
*/
|
|
44
|
+
teardown?: (() => void)[];
|
|
40
45
|
}
|
|
41
46
|
interface TestHooks {
|
|
42
47
|
beforeEach: () => void;
|
|
@@ -37,6 +37,11 @@ interface TestContext {
|
|
|
37
37
|
url?: string;
|
|
38
38
|
serverProcess?: ExecaChildProcess;
|
|
39
39
|
mockFn?: Function;
|
|
40
|
+
/**
|
|
41
|
+
* Functions to run on the vitest `afterAll` hook.
|
|
42
|
+
* Useful for removing anything created during the test.
|
|
43
|
+
*/
|
|
44
|
+
teardown?: (() => void)[];
|
|
40
45
|
}
|
|
41
46
|
interface TestHooks {
|
|
42
47
|
beforeEach: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u as useTestContext, a as url, c as createTestContext, s as setTestContext, b as stopServer, d as startServer } from './shared/test-utils-nightly.ddf5bsCK.mjs';
|
|
2
2
|
export { $ as $fetch, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv } from './shared/test-utils-nightly.ddf5bsCK.mjs';
|
|
3
3
|
import { consola } from 'consola';
|
|
4
|
-
import {
|
|
4
|
+
import { existsSync, promises } from 'node:fs';
|
|
5
5
|
import { resolve } from 'node:path';
|
|
6
6
|
import { defu } from 'defu';
|
|
7
7
|
import * as _kit from '@nuxt/kit';
|
|
@@ -83,12 +83,12 @@ async function loadFixture() {
|
|
|
83
83
|
ctx.options.rootDir = resolveRootDir();
|
|
84
84
|
if (!ctx.options.dev) {
|
|
85
85
|
const randomId = Math.random().toString(36).slice(2, 8);
|
|
86
|
-
const
|
|
86
|
+
const buildDir2 = ctx.options.buildDir || resolve(ctx.options.rootDir, ".nuxt", "test", randomId);
|
|
87
87
|
ctx.options.nuxtConfig = defu(ctx.options.nuxtConfig, {
|
|
88
|
-
buildDir,
|
|
88
|
+
buildDir: buildDir2,
|
|
89
89
|
nitro: {
|
|
90
90
|
output: {
|
|
91
|
-
dir: resolve(
|
|
91
|
+
dir: resolve(buildDir2, "output")
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -99,7 +99,12 @@ async function loadFixture() {
|
|
|
99
99
|
overrides: ctx.options.nuxtConfig,
|
|
100
100
|
configFile: ctx.options.configFile
|
|
101
101
|
});
|
|
102
|
-
|
|
102
|
+
const buildDir = ctx.nuxt.options.buildDir;
|
|
103
|
+
if (!existsSync(buildDir)) {
|
|
104
|
+
await promises.mkdir(buildDir, { recursive: true });
|
|
105
|
+
ctx.teardown = ctx.teardown || [];
|
|
106
|
+
ctx.teardown.push(() => promises.rm(buildDir, { recursive: true, force: true }));
|
|
107
|
+
}
|
|
103
108
|
}
|
|
104
109
|
async function buildFixture() {
|
|
105
110
|
const ctx = useTestContext();
|
|
@@ -151,6 +156,7 @@ function createTest(options) {
|
|
|
151
156
|
if (ctx.browser) {
|
|
152
157
|
await ctx.browser.close();
|
|
153
158
|
}
|
|
159
|
+
await Promise.all((ctx.teardown || []).map((fn) => fn()));
|
|
154
160
|
};
|
|
155
161
|
const setup2 = async () => {
|
|
156
162
|
if (ctx.options.fixture) {
|
package/dist/module.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import MagicString from 'magic-string';
|
|
|
12
12
|
import { normalize, resolve } from 'node:path';
|
|
13
13
|
import { createUnplugin } from 'unplugin';
|
|
14
14
|
import { readFileSync } from 'node:fs';
|
|
15
|
+
import { extname, join, dirname } from 'pathe';
|
|
15
16
|
|
|
16
17
|
const PLUGIN_NAME$1 = "nuxt:vitest:mock-transform";
|
|
17
18
|
const HELPER_MOCK_IMPORT = "mockNuxtImport";
|
|
@@ -224,7 +225,7 @@ const createMockPlugin = (ctx) => createUnplugin(() => {
|
|
|
224
225
|
resolvedFirstSetupFile = await resolvePath(normalize(resolve(firstSetupFile)));
|
|
225
226
|
}
|
|
226
227
|
const plugins = config.plugins || [];
|
|
227
|
-
const vitestPlugins = plugins.filter((p) => p.name === "vite:mocks" || p.name.startsWith("vitest:"));
|
|
228
|
+
const vitestPlugins = plugins.filter((p) => (p.name === "vite:mocks" || p.name.startsWith("vitest:")) && (p.enforce || p.order) === "post");
|
|
228
229
|
const lastNuxt = findLastIndex(
|
|
229
230
|
plugins,
|
|
230
231
|
(i) => i.name?.startsWith("nuxt:")
|
|
@@ -300,18 +301,20 @@ function setupImportMocking() {
|
|
|
300
301
|
}
|
|
301
302
|
|
|
302
303
|
const PLUGIN_NAME = "nuxt:vitest:nuxt-root-stub";
|
|
304
|
+
const STUB_ID = "nuxt-vitest-app-entry";
|
|
303
305
|
const NuxtRootStubPlugin = createUnplugin((options) => {
|
|
306
|
+
const STUB_ID_WITH_EXT = STUB_ID + extname(options.entry);
|
|
304
307
|
return {
|
|
305
308
|
name: PLUGIN_NAME,
|
|
306
309
|
enforce: "pre",
|
|
307
310
|
vite: {
|
|
308
|
-
async resolveId(id) {
|
|
309
|
-
if (id.endsWith(
|
|
310
|
-
return id;
|
|
311
|
+
async resolveId(id, importer) {
|
|
312
|
+
if (id.endsWith(STUB_ID) || id.endsWith(STUB_ID_WITH_EXT)) {
|
|
313
|
+
return importer?.endsWith("index.html") ? id : join(dirname(options.entry), STUB_ID_WITH_EXT);
|
|
311
314
|
}
|
|
312
315
|
},
|
|
313
316
|
async load(id) {
|
|
314
|
-
if (id.endsWith(
|
|
317
|
+
if (id.endsWith(STUB_ID) || id.endsWith(STUB_ID_WITH_EXT)) {
|
|
315
318
|
const entryContents = readFileSync(options.entry, "utf-8");
|
|
316
319
|
return entryContents.replace("#build/root-component.mjs", options.rootStubPath);
|
|
317
320
|
}
|
|
@@ -320,7 +323,7 @@ const NuxtRootStubPlugin = createUnplugin((options) => {
|
|
|
320
323
|
};
|
|
321
324
|
});
|
|
322
325
|
|
|
323
|
-
const vitePluginBlocklist = ["vite-plugin-vue-inspector", "vite-plugin-inspect"];
|
|
326
|
+
const vitePluginBlocklist = ["vite-plugin-vue-inspector", "vite-plugin-vue-inspector:post", "vite-plugin-inspect"];
|
|
324
327
|
const module = defineNuxtModule({
|
|
325
328
|
meta: {
|
|
326
329
|
name: "@nuxt/test-utils",
|
|
@@ -341,9 +344,6 @@ const module = defineNuxtModule({
|
|
|
341
344
|
}));
|
|
342
345
|
if (!nuxt.options.dev)
|
|
343
346
|
return;
|
|
344
|
-
if (nuxt.options.test && nuxt.options.app.rootId === "__nuxt") {
|
|
345
|
-
nuxt.options.app.rootId = "nuxt-test";
|
|
346
|
-
}
|
|
347
347
|
if (process.env.TEST || process.env.VITE_TEST)
|
|
348
348
|
return;
|
|
349
349
|
const rawViteConfigPromise = new Promise((resolve) => {
|
|
@@ -354,8 +354,6 @@ const module = defineNuxtModule({
|
|
|
354
354
|
});
|
|
355
355
|
});
|
|
356
356
|
});
|
|
357
|
-
const PORT = await getPort({ port: 15555 });
|
|
358
|
-
const URL = `http://localhost:${PORT}/__vitest__/`;
|
|
359
357
|
let loaded = false;
|
|
360
358
|
let promise;
|
|
361
359
|
let ctx = void 0;
|
|
@@ -363,6 +361,7 @@ const module = defineNuxtModule({
|
|
|
363
361
|
const updateTabs = debounce(() => {
|
|
364
362
|
nuxt.callHook("devtools:customTabs:refresh");
|
|
365
363
|
}, 100);
|
|
364
|
+
let URL;
|
|
366
365
|
async function start() {
|
|
367
366
|
const rawViteConfig = mergeConfig({}, await rawViteConfigPromise);
|
|
368
367
|
const viteConfig = await getVitestConfigFromNuxt({ nuxt, viteConfig: defu({ test: options.vitestConfig }, rawViteConfig) });
|
|
@@ -385,6 +384,9 @@ const module = defineNuxtModule({
|
|
|
385
384
|
}
|
|
386
385
|
};
|
|
387
386
|
const watchMode = !process.env.NUXT_VITEST_DEV_TEST && !isCI;
|
|
387
|
+
const PORT = await getPort({ port: 15555 });
|
|
388
|
+
const PROTOCOL = nuxt.options.devServer.https ? "https" : "http";
|
|
389
|
+
URL = `${PROTOCOL}://localhost:${PORT}/__vitest__/`;
|
|
388
390
|
const overrides = watchMode ? {
|
|
389
391
|
passWithNoTests: true,
|
|
390
392
|
reporters: options.logToConsole ? [
|
package/dist/runtime/entry.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
if (typeof window !== "undefined" && // @ts-expect-error undefined property
|
|
2
2
|
window.__NUXT_VITEST_ENVIRONMENT__) {
|
|
3
|
+
const { useRouter } = await import("#app/composables/router");
|
|
3
4
|
await import("#app/nuxt-vitest-app-entry").then((r) => r.default());
|
|
4
5
|
const nuxtApp = useNuxtApp();
|
|
5
6
|
await nuxtApp.callHook("page:finish");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _kit from "@nuxt/kit";
|
|
2
|
-
import { createTest, exposeContextToEnv } from "@nuxt/test-utils";
|
|
2
|
+
import { createTest, exposeContextToEnv } from "@nuxt/test-utils/e2e";
|
|
3
3
|
const kit = _kit.default || _kit;
|
|
4
4
|
const options = JSON.parse(process.env.NUXT_TEST_OPTIONS || "{}");
|
|
5
5
|
const hooks = createTest(options);
|
|
@@ -13,7 +13,7 @@ type OptionalFunction<T> = T | (() => Awaitable<T>);
|
|
|
13
13
|
* @param options - factory function that returns the mocked data or an object containing both the `handler` and the `method` properties.
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
|
-
* import { registerEndpoint } from '@nuxt/test-utils/runtime
|
|
16
|
+
* import { registerEndpoint } from '@nuxt/test-utils/runtime'
|
|
17
17
|
*
|
|
18
18
|
* registerEndpoint("/test/", () => {
|
|
19
19
|
* test: "test-field"
|
|
@@ -31,7 +31,7 @@ declare function registerEndpoint(url: string, options: EventHandler | {
|
|
|
31
31
|
* @param _factory - factory function that returns mocked import.
|
|
32
32
|
* @example
|
|
33
33
|
* ```ts
|
|
34
|
-
* import { mockNuxtImport } from '@nuxt/test-utils/runtime
|
|
34
|
+
* import { mockNuxtImport } from '@nuxt/test-utils/runtime'
|
|
35
35
|
*
|
|
36
36
|
* mockNuxtImport('useStorage', () => {
|
|
37
37
|
* return () => {
|
|
@@ -48,7 +48,7 @@ declare function mockNuxtImport<T = any>(_name: string, _factory: () => T | Prom
|
|
|
48
48
|
* @param setup - factory function that returns the mocked component.
|
|
49
49
|
* @example
|
|
50
50
|
* ```ts
|
|
51
|
-
* import { mockComponent } from '@nuxt/test-utils/runtime
|
|
51
|
+
* import { mockComponent } from '@nuxt/test-utils/runtime'
|
|
52
52
|
*
|
|
53
53
|
* mockComponent('MyComponent', {
|
|
54
54
|
* props: {
|
|
@@ -123,7 +123,7 @@ type RenderOptions = RenderOptions$1 & {
|
|
|
123
123
|
*
|
|
124
124
|
* ```ts
|
|
125
125
|
* // tests/components/SomeComponents.nuxt.spec.ts
|
|
126
|
-
* import { renderSuspended } from '@nuxt/test-utils/runtime
|
|
126
|
+
* import { renderSuspended } from '@nuxt/test-utils/runtime'
|
|
127
127
|
*
|
|
128
128
|
* it('can render some component', async () => {
|
|
129
129
|
* const { html } = await renderSuspended(SomeComponent)
|
|
@@ -134,7 +134,7 @@ type RenderOptions = RenderOptions$1 & {
|
|
|
134
134
|
* })
|
|
135
135
|
*
|
|
136
136
|
* // tests/App.nuxt.spec.ts
|
|
137
|
-
* import { renderSuspended } from '@nuxt/test-utils/runtime
|
|
137
|
+
* import { renderSuspended } from '@nuxt/test-utils/runtime'
|
|
138
138
|
* import { screen } from '@testing-library/vue'
|
|
139
139
|
*
|
|
140
140
|
* it('can also mount an app', async () => {
|
|
@@ -13,7 +13,7 @@ type OptionalFunction<T> = T | (() => Awaitable<T>);
|
|
|
13
13
|
* @param options - factory function that returns the mocked data or an object containing both the `handler` and the `method` properties.
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
|
-
* import { registerEndpoint } from '@nuxt/test-utils/runtime
|
|
16
|
+
* import { registerEndpoint } from '@nuxt/test-utils/runtime'
|
|
17
17
|
*
|
|
18
18
|
* registerEndpoint("/test/", () => {
|
|
19
19
|
* test: "test-field"
|
|
@@ -31,7 +31,7 @@ declare function registerEndpoint(url: string, options: EventHandler | {
|
|
|
31
31
|
* @param _factory - factory function that returns mocked import.
|
|
32
32
|
* @example
|
|
33
33
|
* ```ts
|
|
34
|
-
* import { mockNuxtImport } from '@nuxt/test-utils/runtime
|
|
34
|
+
* import { mockNuxtImport } from '@nuxt/test-utils/runtime'
|
|
35
35
|
*
|
|
36
36
|
* mockNuxtImport('useStorage', () => {
|
|
37
37
|
* return () => {
|
|
@@ -48,7 +48,7 @@ declare function mockNuxtImport<T = any>(_name: string, _factory: () => T | Prom
|
|
|
48
48
|
* @param setup - factory function that returns the mocked component.
|
|
49
49
|
* @example
|
|
50
50
|
* ```ts
|
|
51
|
-
* import { mockComponent } from '@nuxt/test-utils/runtime
|
|
51
|
+
* import { mockComponent } from '@nuxt/test-utils/runtime'
|
|
52
52
|
*
|
|
53
53
|
* mockComponent('MyComponent', {
|
|
54
54
|
* props: {
|
|
@@ -123,7 +123,7 @@ type RenderOptions = RenderOptions$1 & {
|
|
|
123
123
|
*
|
|
124
124
|
* ```ts
|
|
125
125
|
* // tests/components/SomeComponents.nuxt.spec.ts
|
|
126
|
-
* import { renderSuspended } from '@nuxt/test-utils/runtime
|
|
126
|
+
* import { renderSuspended } from '@nuxt/test-utils/runtime'
|
|
127
127
|
*
|
|
128
128
|
* it('can render some component', async () => {
|
|
129
129
|
* const { html } = await renderSuspended(SomeComponent)
|
|
@@ -134,7 +134,7 @@ type RenderOptions = RenderOptions$1 & {
|
|
|
134
134
|
* })
|
|
135
135
|
*
|
|
136
136
|
* // tests/App.nuxt.spec.ts
|
|
137
|
-
* import { renderSuspended } from '@nuxt/test-utils/runtime
|
|
137
|
+
* import { renderSuspended } from '@nuxt/test-utils/runtime'
|
|
138
138
|
* import { screen } from '@testing-library/vue'
|
|
139
139
|
*
|
|
140
140
|
* it('can also mount an app', async () => {
|
|
@@ -102,19 +102,21 @@ async function mountSuspended(component, options) {
|
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
default: () => h$1({
|
|
105
|
+
name: "MountSuspendedHelper",
|
|
105
106
|
async setup() {
|
|
106
107
|
const router = useRouter();
|
|
107
108
|
await router.replace(route);
|
|
108
109
|
const clonedComponent = {
|
|
110
|
+
name: "MountSuspendedComponent",
|
|
109
111
|
...component,
|
|
110
|
-
render: render ? (_ctx, ...args)
|
|
111
|
-
for (const key in
|
|
112
|
+
render: render ? function(_ctx, ...args) {
|
|
113
|
+
for (const key in props || {}) {
|
|
112
114
|
renderContext[key] = _ctx[key];
|
|
113
115
|
}
|
|
114
|
-
|
|
115
|
-
renderContext
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
for (const key in setupState || {}) {
|
|
117
|
+
renderContext[key] = setupState[key];
|
|
118
|
+
}
|
|
119
|
+
return render.call(this, renderContext, ...args);
|
|
118
120
|
} : void 0,
|
|
119
121
|
setup: setup ? (props2) => wrappedSetup(props2, setupContext) : void 0
|
|
120
122
|
};
|
|
@@ -124,16 +126,24 @@ async function mountSuspended(component, options) {
|
|
|
124
126
|
}
|
|
125
127
|
)
|
|
126
128
|
},
|
|
127
|
-
defu(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
defu(
|
|
130
|
+
_options,
|
|
131
|
+
{
|
|
132
|
+
slots,
|
|
133
|
+
global: {
|
|
134
|
+
config: {
|
|
135
|
+
globalProperties: vueApp.config.globalProperties
|
|
136
|
+
},
|
|
137
|
+
provide: vueApp._context.provides,
|
|
138
|
+
stubs: {
|
|
139
|
+
Suspense: false,
|
|
140
|
+
MountSuspendedHelper: false,
|
|
141
|
+
[typeof component.name === "string" ? component.name : "MountSuspendedComponent"]: false
|
|
142
|
+
},
|
|
143
|
+
components: { RouterLink }
|
|
144
|
+
}
|
|
135
145
|
}
|
|
136
|
-
|
|
146
|
+
)
|
|
137
147
|
);
|
|
138
148
|
}
|
|
139
149
|
);
|
|
@@ -151,6 +161,7 @@ async function renderSuspended(component, options) {
|
|
|
151
161
|
const { render: renderFromTestingLibrary } = await import('@testing-library/vue');
|
|
152
162
|
const { vueApp } = globalThis.__unctx__.get("nuxt-app").tryUse();
|
|
153
163
|
const { render, setup } = component;
|
|
164
|
+
document.querySelector(`#${WRAPPER_EL_ID}`)?.remove();
|
|
154
165
|
let setupContext;
|
|
155
166
|
return new Promise((resolve) => {
|
|
156
167
|
const utils = renderFromTestingLibrary(
|
package/e2e.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/e2e'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/test-utils-nightly",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-1702810232.fba662c",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/test-utils.git"
|
|
@@ -8,21 +8,23 @@
|
|
|
8
8
|
"description": "Test utilities for Nuxt",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
11
|
-
"types": "./dist/
|
|
11
|
+
"types": "./dist/e2e.d.ts",
|
|
12
12
|
"exports": {
|
|
13
|
-
".": "./dist/
|
|
13
|
+
".": "./dist/e2e.mjs",
|
|
14
14
|
"./config": "./dist/config.mjs",
|
|
15
|
+
"./e2e": "./dist/e2e.mjs",
|
|
15
16
|
"./experimental": "./dist/experimental.mjs",
|
|
16
17
|
"./module": "./dist/module.mjs",
|
|
17
|
-
"./runtime
|
|
18
|
+
"./runtime": "./dist/runtime-utils/index.mjs",
|
|
18
19
|
"./vitest-environment": "./dist/vitest-environment.mjs"
|
|
19
20
|
},
|
|
20
21
|
"files": [
|
|
21
22
|
"dist",
|
|
22
23
|
"config.d.ts",
|
|
24
|
+
"e2e.d.ts",
|
|
23
25
|
"experimental.d.ts",
|
|
24
26
|
"module.d.ts",
|
|
25
|
-
"runtime
|
|
27
|
+
"runtime.d.ts",
|
|
26
28
|
"vitest-environment.d.ts"
|
|
27
29
|
],
|
|
28
30
|
"scripts": {
|
|
@@ -55,46 +57,49 @@
|
|
|
55
57
|
"ufo": "^1.3.2",
|
|
56
58
|
"unenv": "^1.8.0",
|
|
57
59
|
"unplugin": "^1.5.1",
|
|
58
|
-
"vitest-environment-nuxt": "0.
|
|
60
|
+
"vitest-environment-nuxt": "1.0.0-alpha.1"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@jest/globals": "29.7.0",
|
|
62
|
-
"@nuxt/devtools": "1.0.
|
|
64
|
+
"@nuxt/devtools": "1.0.6",
|
|
63
65
|
"@nuxt/eslint-config": "0.2.0",
|
|
64
66
|
"@nuxt/module-builder": "0.5.4",
|
|
65
67
|
"@testing-library/vue": "8.0.1",
|
|
66
68
|
"@types/estree": "1.0.5",
|
|
67
69
|
"@types/jsdom": "21.1.6",
|
|
68
|
-
"@
|
|
70
|
+
"@types/semver": "7.5.6",
|
|
71
|
+
"@vitest/ui": "1.0.4",
|
|
69
72
|
"@vue/test-utils": "2.4.3",
|
|
70
73
|
"changelogen": "0.5.5",
|
|
71
|
-
"eslint": "8.
|
|
72
|
-
"eslint-plugin-import": "2.29.
|
|
73
|
-
"eslint-plugin-jsdoc": "46.9.
|
|
74
|
+
"eslint": "8.56.0",
|
|
75
|
+
"eslint-plugin-import": "2.29.1",
|
|
76
|
+
"eslint-plugin-jsdoc": "46.9.1",
|
|
74
77
|
"eslint-plugin-no-only-tests": "3.1.0",
|
|
75
78
|
"eslint-plugin-unicorn": "49.0.0",
|
|
76
79
|
"h3": "1.9.0",
|
|
80
|
+
"jiti": "1.21.0",
|
|
77
81
|
"nuxt": "3.8.2",
|
|
78
82
|
"playwright-core": "1.40.1",
|
|
79
|
-
"rollup": "4.
|
|
83
|
+
"rollup": "4.9.1",
|
|
84
|
+
"semver": "7.5.4",
|
|
80
85
|
"unbuild": "latest",
|
|
81
|
-
"unimport": "3.6.
|
|
82
|
-
"vite": "5.0.
|
|
83
|
-
"vitest": "0.
|
|
86
|
+
"unimport": "3.6.1",
|
|
87
|
+
"vite": "5.0.10",
|
|
88
|
+
"vitest": "1.0.4",
|
|
84
89
|
"vue-router": "4.2.5",
|
|
85
|
-
"vue-tsc": "1.8.
|
|
90
|
+
"vue-tsc": "1.8.25"
|
|
86
91
|
},
|
|
87
92
|
"peerDependencies": {
|
|
88
93
|
"@jest/globals": "^29.5.0",
|
|
89
94
|
"@testing-library/vue": "^7.0.0 || ^8.0.1",
|
|
90
|
-
"@vitest/ui": "0.
|
|
95
|
+
"@vitest/ui": "^0.34.6 || ^1.0.0",
|
|
91
96
|
"@vue/test-utils": "^2.4.2",
|
|
92
97
|
"h3": "*",
|
|
93
98
|
"happy-dom": "^9.10.9 || ^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
94
99
|
"jsdom": "^22.0.0 || ^23.0.0",
|
|
95
100
|
"playwright-core": "^1.34.3",
|
|
96
101
|
"vite": "*",
|
|
97
|
-
"vitest": "^0.
|
|
102
|
+
"vitest": "^0.34.6 || ^1.0.0",
|
|
98
103
|
"vue": "^3.3.4",
|
|
99
104
|
"vue-router": "^4.0.0"
|
|
100
105
|
},
|
|
@@ -126,12 +131,11 @@
|
|
|
126
131
|
},
|
|
127
132
|
"resolutions": {
|
|
128
133
|
"@nuxt/test-utils": "workspace:*",
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"vite": "5.0.4"
|
|
134
|
+
"rollup": "4.9.1",
|
|
135
|
+
"vite": "5.0.10"
|
|
132
136
|
},
|
|
133
137
|
"engines": {
|
|
134
138
|
"node": "^14.18.0 || >=16.10.0"
|
|
135
139
|
},
|
|
136
|
-
"packageManager": "pnpm@8.
|
|
140
|
+
"packageManager": "pnpm@8.12.1"
|
|
137
141
|
}
|
package/runtime.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/runtime-utils/index.mjs'
|
package/runtime-utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/runtime-utils'
|