@nuxt/test-utils-nightly 3.8.2-1700569433.604c6dd → 3.8.2-1701343322.6d8e71a
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/dist/config.d.mts +46 -4
- package/dist/config.d.ts +46 -4
- package/dist/config.mjs +149 -1
- package/dist/experimental.mjs +1 -1
- package/dist/index.mjs +6 -3
- package/dist/module.d.mts +11 -1
- package/dist/module.d.ts +11 -1
- package/dist/module.mjs +442 -1
- package/dist/runtime-utils.d.mts +150 -1
- package/dist/runtime-utils.d.ts +150 -1
- package/dist/runtime-utils.mjs +212 -1
- package/dist/vitest-environment.d.mts +21 -1
- package/dist/vitest-environment.d.ts +21 -1
- package/dist/vitest-environment.mjs +175 -1
- package/module.d.ts +1 -1
- package/package.json +29 -21
- package/vitest-environment.d.ts +1 -1
- /package/dist/shared/{test-utils-nightly.8f432eb9.mjs → test-utils-nightly.ddf5bsCK.mjs} +0 -0
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
import 'vitest
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { InlineConfig } from 'vite';
|
|
3
|
+
import { NuxtConfig, Nuxt } from '@nuxt/schema';
|
|
4
|
+
import { InlineConfig as InlineConfig$1 } from 'vitest';
|
|
5
|
+
|
|
6
|
+
interface GetVitestConfigOptions {
|
|
7
|
+
nuxt: Nuxt;
|
|
8
|
+
viteConfig: InlineConfig;
|
|
9
|
+
}
|
|
10
|
+
declare function getVitestConfigFromNuxt(options?: GetVitestConfigOptions, overrides?: NuxtConfig): Promise<InlineConfig & {
|
|
11
|
+
test: InlineConfig$1;
|
|
12
|
+
}>;
|
|
13
|
+
declare function defineVitestConfig(config?: InlineConfig & {
|
|
14
|
+
test?: InlineConfig$1;
|
|
15
|
+
}): vite.UserConfig & Promise<vite.UserConfig> & vite.UserConfigFnObject & vite.UserConfigExport;
|
|
16
|
+
declare module 'vitest' {
|
|
17
|
+
interface EnvironmentOptions {
|
|
18
|
+
nuxt?: {
|
|
19
|
+
rootDir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The starting URL for your Nuxt window environment
|
|
22
|
+
* @default {http://localhost:3000}
|
|
23
|
+
*/
|
|
24
|
+
url?: string;
|
|
25
|
+
overrides?: NuxtConfig;
|
|
26
|
+
/**
|
|
27
|
+
* The id of the root div to which the app should be mounted. You should also set `app.rootId` to the same value.
|
|
28
|
+
* @default {nuxt-test}
|
|
29
|
+
*/
|
|
30
|
+
rootId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the DOM environment to use.
|
|
33
|
+
*
|
|
34
|
+
* It also needs to be installed as a dev dependency in your project.
|
|
35
|
+
* @default {happy-dom}
|
|
36
|
+
*/
|
|
37
|
+
domEnvironment?: 'happy-dom' | 'jsdom';
|
|
38
|
+
mock?: {
|
|
39
|
+
intersectionObserver?: boolean;
|
|
40
|
+
indexedDb?: boolean;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { defineVitestConfig, getVitestConfigFromNuxt };
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
import 'vitest
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { InlineConfig } from 'vite';
|
|
3
|
+
import { NuxtConfig, Nuxt } from '@nuxt/schema';
|
|
4
|
+
import { InlineConfig as InlineConfig$1 } from 'vitest';
|
|
5
|
+
|
|
6
|
+
interface GetVitestConfigOptions {
|
|
7
|
+
nuxt: Nuxt;
|
|
8
|
+
viteConfig: InlineConfig;
|
|
9
|
+
}
|
|
10
|
+
declare function getVitestConfigFromNuxt(options?: GetVitestConfigOptions, overrides?: NuxtConfig): Promise<InlineConfig & {
|
|
11
|
+
test: InlineConfig$1;
|
|
12
|
+
}>;
|
|
13
|
+
declare function defineVitestConfig(config?: InlineConfig & {
|
|
14
|
+
test?: InlineConfig$1;
|
|
15
|
+
}): vite.UserConfig & Promise<vite.UserConfig> & vite.UserConfigFnObject & vite.UserConfigExport;
|
|
16
|
+
declare module 'vitest' {
|
|
17
|
+
interface EnvironmentOptions {
|
|
18
|
+
nuxt?: {
|
|
19
|
+
rootDir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The starting URL for your Nuxt window environment
|
|
22
|
+
* @default {http://localhost:3000}
|
|
23
|
+
*/
|
|
24
|
+
url?: string;
|
|
25
|
+
overrides?: NuxtConfig;
|
|
26
|
+
/**
|
|
27
|
+
* The id of the root div to which the app should be mounted. You should also set `app.rootId` to the same value.
|
|
28
|
+
* @default {nuxt-test}
|
|
29
|
+
*/
|
|
30
|
+
rootId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the DOM environment to use.
|
|
33
|
+
*
|
|
34
|
+
* It also needs to be installed as a dev dependency in your project.
|
|
35
|
+
* @default {happy-dom}
|
|
36
|
+
*/
|
|
37
|
+
domEnvironment?: 'happy-dom' | 'jsdom';
|
|
38
|
+
mock?: {
|
|
39
|
+
intersectionObserver?: boolean;
|
|
40
|
+
indexedDb?: boolean;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { defineVitestConfig, getVitestConfigFromNuxt };
|
package/dist/config.mjs
CHANGED
|
@@ -1 +1,149 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import vuePlugin from '@vitejs/plugin-vue';
|
|
3
|
+
import viteJsxPlugin from '@vitejs/plugin-vue-jsx';
|
|
4
|
+
import { defu } from 'defu';
|
|
5
|
+
|
|
6
|
+
async function startNuxtAndGetViteConfig(rootDir = process.cwd(), overrides) {
|
|
7
|
+
const { loadNuxt, buildNuxt } = await import('@nuxt/kit');
|
|
8
|
+
const nuxt = await loadNuxt({
|
|
9
|
+
cwd: rootDir,
|
|
10
|
+
dev: false,
|
|
11
|
+
overrides: defu(
|
|
12
|
+
{
|
|
13
|
+
ssr: false,
|
|
14
|
+
test: true,
|
|
15
|
+
modules: ["@nuxt/test-utils/module"]
|
|
16
|
+
},
|
|
17
|
+
overrides
|
|
18
|
+
)
|
|
19
|
+
});
|
|
20
|
+
if (!nuxt.options._installedModules.find((i) => i?.meta?.name === "@nuxt/test-utils")) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
"Failed to load nuxt-vitest module. You may need to add it to your nuxt.config."
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const promise = new Promise((resolve, reject) => {
|
|
26
|
+
nuxt.hook("vite:extendConfig", (viteConfig, { isClient }) => {
|
|
27
|
+
if (isClient) {
|
|
28
|
+
resolve({ nuxt, viteConfig });
|
|
29
|
+
throw new Error("_stop_");
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
buildNuxt(nuxt).catch((err) => {
|
|
33
|
+
if (!err.toString().includes("_stop_")) {
|
|
34
|
+
reject(err);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}).finally(() => nuxt.close());
|
|
38
|
+
return promise;
|
|
39
|
+
}
|
|
40
|
+
const vuePlugins = {
|
|
41
|
+
"vite:vue": [vuePlugin, "vue"],
|
|
42
|
+
"vite:vue-jsx": [viteJsxPlugin, "vueJsx"]
|
|
43
|
+
};
|
|
44
|
+
async function getVitestConfigFromNuxt(options, overrides) {
|
|
45
|
+
const { rootDir = process.cwd(), ..._overrides } = overrides || {};
|
|
46
|
+
if (!options)
|
|
47
|
+
options = await startNuxtAndGetViteConfig(rootDir, {
|
|
48
|
+
test: true,
|
|
49
|
+
..._overrides
|
|
50
|
+
});
|
|
51
|
+
options.viteConfig.plugins = options.viteConfig.plugins || [];
|
|
52
|
+
options.viteConfig.plugins = options.viteConfig.plugins.filter(
|
|
53
|
+
(p) => p?.name !== "nuxt:import-protection"
|
|
54
|
+
);
|
|
55
|
+
for (const name in vuePlugins) {
|
|
56
|
+
if (!options.viteConfig.plugins?.some((p) => p?.name === name)) {
|
|
57
|
+
const [plugin, key] = vuePlugins[name];
|
|
58
|
+
options.viteConfig.plugins.unshift(
|
|
59
|
+
// @ts-expect-error mismatching component options
|
|
60
|
+
plugin(options.viteConfig[key])
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const resolvedConfig = defu(
|
|
65
|
+
// overrides
|
|
66
|
+
{
|
|
67
|
+
define: {
|
|
68
|
+
["process.env.NODE_ENV"]: "process.env.NODE_ENV"
|
|
69
|
+
},
|
|
70
|
+
test: {
|
|
71
|
+
dir: process.cwd(),
|
|
72
|
+
environmentOptions: {
|
|
73
|
+
nuxtRuntimeConfig: options.nuxt.options.runtimeConfig,
|
|
74
|
+
nuxtRouteRules: defu(
|
|
75
|
+
{},
|
|
76
|
+
options.nuxt.options.routeRules,
|
|
77
|
+
options.nuxt.options.nitro?.routeRules
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
environmentMatchGlobs: [
|
|
81
|
+
["**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}", "nuxt"],
|
|
82
|
+
["{test,tests}/nuxt/**.*", "nuxt"]
|
|
83
|
+
],
|
|
84
|
+
deps: {
|
|
85
|
+
inline: [
|
|
86
|
+
// vite-node defaults
|
|
87
|
+
/\/node_modules\/(.*\/)?(nuxt|nuxt3|nuxt-nightly)\//,
|
|
88
|
+
/^#/,
|
|
89
|
+
// additional deps
|
|
90
|
+
"@nuxt/test-utils",
|
|
91
|
+
"vitest-environment-nuxt",
|
|
92
|
+
...options.nuxt.options.build.transpile.filter(
|
|
93
|
+
(r) => typeof r === "string" || r instanceof RegExp
|
|
94
|
+
)
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
server: { middlewareMode: false },
|
|
101
|
+
plugins: [
|
|
102
|
+
{
|
|
103
|
+
name: "disable-auto-execute",
|
|
104
|
+
enforce: "pre",
|
|
105
|
+
transform(code, id) {
|
|
106
|
+
if (id.match(/nuxt(3|-nightly)?\/.*\/entry\./)) {
|
|
107
|
+
return code.replace(
|
|
108
|
+
/(?<!vueAppPromise = )entry\(\)\.catch/,
|
|
109
|
+
"Promise.resolve().catch"
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
// resolved vite config
|
|
117
|
+
options.viteConfig,
|
|
118
|
+
// (overrideable) defaults
|
|
119
|
+
{
|
|
120
|
+
test: {
|
|
121
|
+
environmentOptions: {
|
|
122
|
+
nuxt: {
|
|
123
|
+
rootId: options.nuxt.options.app.rootId || void 0,
|
|
124
|
+
mock: {
|
|
125
|
+
intersectionObserver: true,
|
|
126
|
+
indexedDb: false
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
delete resolvedConfig.define["process.browser"];
|
|
134
|
+
return resolvedConfig;
|
|
135
|
+
}
|
|
136
|
+
function defineVitestConfig(config = {}) {
|
|
137
|
+
return defineConfig(async () => {
|
|
138
|
+
if (process.env.__NUXT_VITEST_RESOLVED__)
|
|
139
|
+
return config;
|
|
140
|
+
const overrides = config.test?.environmentOptions?.nuxt?.overrides || {};
|
|
141
|
+
overrides.rootDir = config.test?.environmentOptions?.nuxt?.rootDir;
|
|
142
|
+
return defu(
|
|
143
|
+
config,
|
|
144
|
+
await getVitestConfigFromNuxt(void 0, overrides)
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { defineVitestConfig, getVitestConfigFromNuxt };
|
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-nightly.
|
|
3
|
+
import { $ as $fetch, u as useTestContext } from './shared/test-utils-nightly.ddf5bsCK.mjs';
|
|
4
4
|
import 'execa';
|
|
5
5
|
import 'get-port-please';
|
|
6
6
|
import 'ofetch';
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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.
|
|
2
|
-
export { $ as $fetch, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv } from './shared/test-utils-nightly.
|
|
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
|
+
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
4
|
import { promises, existsSync } from 'node:fs';
|
|
5
5
|
import { resolve } from 'node:path';
|
|
@@ -15,7 +15,10 @@ async function createBrowser() {
|
|
|
15
15
|
const ctx = useTestContext();
|
|
16
16
|
let playwright;
|
|
17
17
|
try {
|
|
18
|
-
playwright = await import(
|
|
18
|
+
playwright = await import(
|
|
19
|
+
/* vite-ignore */
|
|
20
|
+
'playwright-core'
|
|
21
|
+
);
|
|
19
22
|
} catch {
|
|
20
23
|
throw new Error(`
|
|
21
24
|
The dependency 'playwright-core' not found.
|
package/dist/module.d.mts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { UserConfig } from 'vitest';
|
|
3
|
+
|
|
4
|
+
interface NuxtVitestOptions {
|
|
5
|
+
startOnBoot?: boolean;
|
|
6
|
+
logToConsole?: boolean;
|
|
7
|
+
vitestConfig?: UserConfig;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: _nuxt_schema.NuxtModule<NuxtVitestOptions>;
|
|
10
|
+
|
|
11
|
+
export { type NuxtVitestOptions, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { UserConfig } from 'vitest';
|
|
3
|
+
|
|
4
|
+
interface NuxtVitestOptions {
|
|
5
|
+
startOnBoot?: boolean;
|
|
6
|
+
logToConsole?: boolean;
|
|
7
|
+
vitestConfig?: UserConfig;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: _nuxt_schema.NuxtModule<NuxtVitestOptions>;
|
|
10
|
+
|
|
11
|
+
export { type NuxtVitestOptions, _default as default };
|