@nuxt/test-utils 3.8.0 → 3.9.0-alpha.1
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 +8 -58
- package/config.d.ts +1 -0
- package/dist/config.d.mts +46 -0
- package/dist/config.d.ts +46 -0
- package/dist/config.mjs +150 -0
- 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} +18 -8
- package/dist/experimental.mjs +1 -1
- package/dist/module.d.mts +11 -0
- package/dist/module.d.ts +11 -0
- package/dist/module.mjs +461 -0
- package/dist/runtime/entry.d.ts +1 -0
- package/dist/runtime/entry.mjs +9 -0
- package/dist/runtime/global-setup.mjs +1 -1
- package/dist/runtime/nuxt-root.d.ts +4 -0
- package/dist/runtime/nuxt-root.mjs +21 -0
- package/dist/runtime-utils/index.d.mts +150 -0
- package/dist/runtime-utils/index.d.ts +150 -0
- package/dist/runtime-utils/index.mjs +223 -0
- package/dist/vitest-environment.d.mts +22 -0
- package/dist/vitest-environment.d.ts +22 -0
- package/dist/vitest-environment.mjs +175 -0
- package/e2e.d.ts +1 -0
- package/experimental.d.ts +1 -0
- package/module.d.ts +1 -0
- package/package.json +101 -21
- package/runtime.d.ts +1 -0
- package/vitest-environment.d.ts +1 -0
- /package/dist/shared/{test-utils.8f432eb9.mjs → test-utils.ddf5bsCK.mjs} +0 -0
package/README.md
CHANGED
|
@@ -1,68 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
# Nuxt Test Utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
🧪 [Nuxt](https://nuxt.com/) Test Utils
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
|
|
7
|
-
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
|
|
8
|
-
<a href="./LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
|
|
9
|
-
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt.js" alt="Website"></a>
|
|
10
|
-
<a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
|
|
11
|
-
</p>
|
|
5
|
+
## Overview
|
|
12
6
|
|
|
13
|
-
Nuxt
|
|
7
|
+
Nuxt offers first-class support for e2e and unit testing of your Nuxt applications.
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
- Server-side rendering, Static Site Generation or Hybrid Rendering
|
|
17
|
-
- Automatic routing with code-splitting
|
|
18
|
-
- State management
|
|
19
|
-
- SEO Optimization
|
|
20
|
-
- Extensible with [100+ modules](https://nuxt.com/modules)
|
|
21
|
-
- Deployment to a variety of hosting platforms
|
|
22
|
-
- ...[and much more](https://nuxt.com) 🚀
|
|
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.
|
|
23
10
|
|
|
24
|
-
|
|
11
|
+
You can find out more about how to use Nuxt Test Utils:
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npx nuxi@latest init <my-project>
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Discover also [nuxt.new](https://nuxt.new): Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds.
|
|
33
|
-
|
|
34
|
-
## Documentation
|
|
35
|
-
|
|
36
|
-
We highly recommend you take a look at the [Nuxt documentation](https://nuxt.com/docs) to level up. It’s a great resource for learning more about the framework. It covers everything from getting started to advanced topics.
|
|
37
|
-
|
|
38
|
-
## Modules
|
|
39
|
-
|
|
40
|
-
Discover our [list of modules](https://nuxt.com/modules) to supercharge your Nuxt project, created by the Nuxt team and community.
|
|
41
|
-
|
|
42
|
-
## Contribute
|
|
43
|
-
|
|
44
|
-
We invite you to contribute and help improve Nuxt 💚
|
|
45
|
-
|
|
46
|
-
Here are a few ways you can get involved:
|
|
47
|
-
- **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/community/reporting-bugs) to learn how to submit a bug report.
|
|
48
|
-
- **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/community/contribution#creating-an-issue) to share your suggestions.
|
|
49
|
-
- **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/community/getting-help) provides resources to help you out.
|
|
50
|
-
|
|
51
|
-
## Local Development
|
|
52
|
-
|
|
53
|
-
Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#setup) to contribute to the framework and documentation.
|
|
54
|
-
|
|
55
|
-
## Nuxt 2
|
|
56
|
-
|
|
57
|
-
You can find the code for Nuxt 2 on the [`2.x` branch](https://github.com/nuxt/nuxt/tree/2.x) and the documentation at [v2.nuxt.com](https://v2.nuxt.com).
|
|
58
|
-
|
|
59
|
-
## Follow us
|
|
60
|
-
|
|
61
|
-
<p valign="center">
|
|
62
|
-
<a href="https://chat.nuxt.dev"><img width="20px" src="./.github/assets/discord.svg" alt="Discord"></a> <a href="https://twitter.nuxt.dev"><img width="20px" src="./.github/assets/twitter.svg" alt="Twitter"></a> <a href="https://github.nuxt.dev"><img width="20px" src="./.github/assets/github.svg" alt="GitHub"></a>
|
|
63
|
-
</p>
|
|
13
|
+
- in [a general overview](https://nuxt.com/docs/getting-started/testing)
|
|
14
|
+
- in [an in-depth guide for module authors](https://nuxt.com/docs/guide/going-further/modules/#testing)
|
|
64
15
|
|
|
65
16
|
## License
|
|
66
17
|
|
|
67
18
|
[MIT](./LICENSE)
|
|
68
|
-
|
package/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/config'
|
|
@@ -0,0 +1,46 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
import { createResolver } from '@nuxt/kit';
|
|
4
|
+
|
|
5
|
+
async function startNuxtAndGetViteConfig(rootDir = process.cwd(), overrides) {
|
|
6
|
+
const { loadNuxt, buildNuxt } = await import('@nuxt/kit');
|
|
7
|
+
const nuxt = await loadNuxt({
|
|
8
|
+
cwd: rootDir,
|
|
9
|
+
dev: false,
|
|
10
|
+
overrides: defu(
|
|
11
|
+
{
|
|
12
|
+
ssr: false,
|
|
13
|
+
test: true,
|
|
14
|
+
modules: ["@nuxt/test-utils/module"]
|
|
15
|
+
},
|
|
16
|
+
overrides
|
|
17
|
+
)
|
|
18
|
+
});
|
|
19
|
+
if (!nuxt.options._installedModules.find((i) => i?.meta?.name === "@nuxt/test-utils")) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"Failed to load `@nuxt/test-utils/module`. You may need to add it to your nuxt.config."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const promise = new Promise((resolve, reject) => {
|
|
25
|
+
nuxt.hook("vite:configResolved", (viteConfig, { isClient }) => {
|
|
26
|
+
if (isClient) {
|
|
27
|
+
resolve({ nuxt, viteConfig });
|
|
28
|
+
throw new Error("_stop_");
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
buildNuxt(nuxt).catch((err) => {
|
|
32
|
+
if (!err.toString().includes("_stop_")) {
|
|
33
|
+
reject(err);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}).finally(() => nuxt.close());
|
|
37
|
+
return promise;
|
|
38
|
+
}
|
|
39
|
+
const excludedPlugins = [
|
|
40
|
+
"nuxt:import-protection",
|
|
41
|
+
"vite-plugin-checker"
|
|
42
|
+
];
|
|
43
|
+
async function getVitestConfigFromNuxt(options, overrides) {
|
|
44
|
+
const { rootDir = process.cwd(), ..._overrides } = overrides || {};
|
|
45
|
+
if (!options) {
|
|
46
|
+
options = await startNuxtAndGetViteConfig(rootDir, {
|
|
47
|
+
test: true,
|
|
48
|
+
..._overrides
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
options.viteConfig.plugins = (options.viteConfig.plugins || []).filter((p) => !excludedPlugins.includes(p?.name));
|
|
52
|
+
const resolvedConfig = defu(
|
|
53
|
+
// overrides
|
|
54
|
+
{
|
|
55
|
+
define: {
|
|
56
|
+
["process.env.NODE_ENV"]: "process.env.NODE_ENV"
|
|
57
|
+
},
|
|
58
|
+
test: {
|
|
59
|
+
dir: process.cwd(),
|
|
60
|
+
environmentOptions: {
|
|
61
|
+
nuxtRuntimeConfig: options.nuxt.options.runtimeConfig,
|
|
62
|
+
nuxtRouteRules: defu(
|
|
63
|
+
{},
|
|
64
|
+
options.nuxt.options.routeRules,
|
|
65
|
+
options.nuxt.options.nitro?.routeRules
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
environmentMatchGlobs: [
|
|
69
|
+
["**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}", "nuxt"],
|
|
70
|
+
["{test,tests}/nuxt/**.*", "nuxt"]
|
|
71
|
+
],
|
|
72
|
+
deps: {
|
|
73
|
+
// TODO: move to server.deps.inline when we update to vite v1
|
|
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
|
+
optimizer: {
|
|
88
|
+
web: {
|
|
89
|
+
enabled: false
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
server: { middlewareMode: false },
|
|
97
|
+
plugins: [
|
|
98
|
+
{
|
|
99
|
+
name: "disable-auto-execute",
|
|
100
|
+
enforce: "pre",
|
|
101
|
+
transform(code, id) {
|
|
102
|
+
if (id.match(/nuxt(3|-nightly)?\/.*\/entry\./)) {
|
|
103
|
+
return code.replace(
|
|
104
|
+
/(?<!vueAppPromise = )entry\(\)\.catch/,
|
|
105
|
+
"Promise.resolve().catch"
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
// resolved vite config
|
|
113
|
+
options.viteConfig,
|
|
114
|
+
// (overrideable) defaults
|
|
115
|
+
{
|
|
116
|
+
test: {
|
|
117
|
+
environmentOptions: {
|
|
118
|
+
nuxt: {
|
|
119
|
+
rootId: options.nuxt.options.app.rootId || void 0,
|
|
120
|
+
mock: {
|
|
121
|
+
intersectionObserver: true,
|
|
122
|
+
indexedDb: false
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
delete resolvedConfig.define["process.browser"];
|
|
130
|
+
if (!Array.isArray(resolvedConfig.test.setupFiles)) {
|
|
131
|
+
resolvedConfig.test.setupFiles = [resolvedConfig.test.setupFiles].filter(Boolean);
|
|
132
|
+
}
|
|
133
|
+
const resolver = createResolver(import.meta.url);
|
|
134
|
+
resolvedConfig.test.setupFiles.unshift(resolver.resolve("./runtime/entry"));
|
|
135
|
+
return resolvedConfig;
|
|
136
|
+
}
|
|
137
|
+
function defineVitestConfig(config = {}) {
|
|
138
|
+
return defineConfig(async () => {
|
|
139
|
+
if (process.env.__NUXT_VITEST_RESOLVED__)
|
|
140
|
+
return config;
|
|
141
|
+
const overrides = config.test?.environmentOptions?.nuxt?.overrides || {};
|
|
142
|
+
overrides.rootDir = config.test?.environmentOptions?.nuxt?.rootDir;
|
|
143
|
+
return defu(
|
|
144
|
+
config,
|
|
145
|
+
await getVitestConfigFromNuxt(void 0, structuredClone(overrides))
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { defineVitestConfig, getVitestConfigFromNuxt };
|
|
@@ -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
|
-
import { u as useTestContext, a as url, c as createTestContext, s as setTestContext, b as stopServer, d as startServer } from './shared/test-utils.
|
|
2
|
-
export { $ as $fetch, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv } from './shared/test-utils.
|
|
1
|
+
import { u as useTestContext, a as url, c as createTestContext, s as setTestContext, b as stopServer, d as startServer } from './shared/test-utils.ddf5bsCK.mjs';
|
|
2
|
+
export { $ as $fetch, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv } from './shared/test-utils.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';
|
|
@@ -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.
|
|
@@ -80,12 +83,12 @@ async function loadFixture() {
|
|
|
80
83
|
ctx.options.rootDir = resolveRootDir();
|
|
81
84
|
if (!ctx.options.dev) {
|
|
82
85
|
const randomId = Math.random().toString(36).slice(2, 8);
|
|
83
|
-
const
|
|
86
|
+
const buildDir2 = ctx.options.buildDir || resolve(ctx.options.rootDir, ".nuxt", "test", randomId);
|
|
84
87
|
ctx.options.nuxtConfig = defu(ctx.options.nuxtConfig, {
|
|
85
|
-
buildDir,
|
|
88
|
+
buildDir: buildDir2,
|
|
86
89
|
nitro: {
|
|
87
90
|
output: {
|
|
88
|
-
dir: resolve(
|
|
91
|
+
dir: resolve(buildDir2, "output")
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
});
|
|
@@ -96,7 +99,12 @@ async function loadFixture() {
|
|
|
96
99
|
overrides: ctx.options.nuxtConfig,
|
|
97
100
|
configFile: ctx.options.configFile
|
|
98
101
|
});
|
|
99
|
-
|
|
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
|
+
}
|
|
100
108
|
}
|
|
101
109
|
async function buildFixture() {
|
|
102
110
|
const ctx = useTestContext();
|
|
@@ -148,6 +156,7 @@ function createTest(options) {
|
|
|
148
156
|
if (ctx.browser) {
|
|
149
157
|
await ctx.browser.close();
|
|
150
158
|
}
|
|
159
|
+
await Promise.all((ctx.teardown || []).map((fn) => fn()));
|
|
151
160
|
};
|
|
152
161
|
const setup2 = async () => {
|
|
153
162
|
if (ctx.options.fixture) {
|
|
@@ -218,6 +227,7 @@ async function runTests(opts) {
|
|
|
218
227
|
inline: [
|
|
219
228
|
distDir,
|
|
220
229
|
"@nuxt/test-utils",
|
|
230
|
+
"@nuxt/test-utils-nightly",
|
|
221
231
|
"@nuxt/test-utils-edge"
|
|
222
232
|
]
|
|
223
233
|
},
|
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.ddf5bsCK.mjs';
|
|
4
4
|
import 'execa';
|
|
5
5
|
import 'get-port-please';
|
|
6
6
|
import 'ofetch';
|
|
@@ -0,0 +1,11 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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 };
|