@nuxt/test-utils 3.15.3 → 3.16.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/dist/config.mjs CHANGED
@@ -23,7 +23,7 @@ function applyEnv(obj, opts, parentKey = "") {
23
23
  if (_isObject(envValue)) {
24
24
  obj[key] = { ...obj[key], ...envValue };
25
25
  applyEnv(obj[key], opts, subKey);
26
- } else if (envValue === undefined) {
26
+ } else if (envValue === void 0) {
27
27
  applyEnv(obj[key], opts, subKey);
28
28
  } else {
29
29
  obj[key] = envValue ?? obj[key];
@@ -172,7 +172,7 @@ async function getVitestConfigFromNuxt(options, loadNuxtOptions = {}) {
172
172
  test: {
173
173
  environmentOptions: {
174
174
  nuxt: {
175
- rootId: options.nuxt.options.app.rootId || undefined,
175
+ rootId: options.nuxt.options.app.rootId || void 0,
176
176
  mock: {
177
177
  intersectionObserver: true,
178
178
  indexedDb: false
@@ -201,7 +201,7 @@ function defineVitestConfig(config = {}) {
201
201
  }
202
202
  return defu(
203
203
  config,
204
- await getVitestConfigFromNuxt(undefined, {
204
+ await getVitestConfigFromNuxt(void 0, {
205
205
  dotenv: config.test?.environmentOptions?.nuxt?.dotenv,
206
206
  overrides: structuredClone(overrides)
207
207
  })
package/dist/e2e.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TestOptions, a as TestContext, b as TestHooks } from './shared/test-utils.DsSnl8Os.mjs';
2
- export { $ as $fetch, G as GotoOptions, N as NuxtPage, S as StartServerOptions, h as TestRunner, c as createBrowser, d as createPage, f as fetch, g as getBrowser, s as startServer, e as stopServer, u as url, w as waitForHydration } from './shared/test-utils.DsSnl8Os.mjs';
1
+ import { T as TestOptions, a as TestContext, b as TestHooks } from './shared/test-utils.DgnIK8xl.mjs';
2
+ export { $ as $fetch, G as GotoOptions, N as NuxtPage, S as StartServerOptions, h as TestRunner, c as createBrowser, d as createPage, f as fetch, g as getBrowser, s as startServer, e as stopServer, u as url, w as waitForHydration } from './shared/test-utils.DgnIK8xl.mjs';
3
3
  import { LogType } from 'consola';
4
4
  import 'playwright-core';
5
5
  import '@nuxt/schema';
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, e as setup, s as setupMaps, w as waitForHydration } from './shared/test-utils.DeQRWngN.mjs';
2
- import { u as useTestContext } from './shared/test-utils.JktOT-Lz.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.JktOT-Lz.mjs';
1
+ export { b as buildFixture, c as createBrowser, a as createPage, d as createTest, g as getBrowser, l as loadFixture, e as setup, s as setupMaps, w as waitForHydration } from './shared/test-utils.BIDY1MqP.mjs';
2
+ import { u as useTestContext } from './shared/test-utils.CHPAu7TP.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.CHPAu7TP.mjs';
4
4
  import { consola } from 'consola';
5
5
  import { resolve } from 'pathe';
6
6
  import { distDir } from '#dirs';
@@ -12,6 +12,7 @@ import 'tinyexec';
12
12
  import 'get-port-please';
13
13
  import 'ofetch';
14
14
  import 'ufo';
15
+ import 'std-env';
15
16
 
16
17
  function mockFn() {
17
18
  const ctx = useTestContext();
@@ -1,12 +1,12 @@
1
1
  import { resolve } from 'pathe';
2
2
  import { stringifyQuery } from 'ufo';
3
- import { $ as $fetch, u as useTestContext } from './shared/test-utils.JktOT-Lz.mjs';
3
+ import { $ as $fetch, u as useTestContext } from './shared/test-utils.CHPAu7TP.mjs';
4
4
  import 'tinyexec';
5
5
  import 'get-port-please';
6
6
  import 'ofetch';
7
- import '@nuxt/kit';
8
7
  import 'node:path';
9
8
  import 'defu';
9
+ import 'std-env';
10
10
 
11
11
  function $fetchComponent(filepath, props) {
12
12
  return $fetch(componentTestUrl(filepath, props));
package/dist/module.mjs CHANGED
@@ -186,7 +186,8 @@ const createMockPlugin = (ctx) => createUnplugin(() => {
186
186
  );
187
187
  }
188
188
  if (!mockLines.length) return;
189
- s.prepend(`vi.hoisted(() => {
189
+ s.appendLeft(insertionPoint, `
190
+ vi.hoisted(() => {
190
191
  if(!globalThis.${HELPER_MOCK_HOIST}){
191
192
  vi.stubGlobal(${JSON.stringify(HELPER_MOCK_HOIST)}, {})
192
193
  }
@@ -194,7 +195,7 @@ const createMockPlugin = (ctx) => createUnplugin(() => {
194
195
  `);
195
196
  if (!hasViImport) s.prepend(`import {vi} from "vitest";
196
197
  `);
197
- s.appendLeft(insertionPoint, mockLines.join("\n") + "\n");
198
+ s.appendLeft(insertionPoint, "\n" + mockLines.join("\n") + "\n");
198
199
  importPathsList.forEach((p) => {
199
200
  s.append(`
200
201
  import ${JSON.stringify(p)};`);
@@ -254,10 +255,10 @@ function isExpressionStatement(node) {
254
255
  return node?.type === "ExpressionStatement";
255
256
  }
256
257
  function startOf(node) {
257
- return "range" in node && node.range ? node.range[0] : "start" in node ? node.start : undefined;
258
+ return "range" in node && node.range ? node.range[0] : "start" in node ? node.start : void 0;
258
259
  }
259
260
  function endOf(node) {
260
- return "range" in node && node.range ? node.range[1] : "end" in node ? node.end : undefined;
261
+ return "range" in node && node.range ? node.range[1] : "end" in node ? node.end : void 0;
261
262
  }
262
263
 
263
264
  function setupImportMocking() {
@@ -351,7 +352,7 @@ const module = defineNuxtModule({
351
352
  });
352
353
  let loaded = false;
353
354
  let promise;
354
- let ctx = undefined;
355
+ let ctx = void 0;
355
356
  let testFiles = null;
356
357
  const updateTabs = debounce(() => {
357
358
  nuxt.callHook("devtools:customTabs:refresh");
@@ -440,7 +441,7 @@ const module = defineNuxtModule({
440
441
  { style: { opacity: "0.8", fontSize: "0.9em" } },
441
442
  totalCount
442
443
  )
443
- ]) : undefined
444
+ ]) : void 0
444
445
  });
445
446
  });
446
447
  if (options.startOnBoot) {
@@ -1,7 +1,7 @@
1
1
  import * as _playwright_test from '@playwright/test';
2
2
  export { expect } from '@playwright/test';
3
3
  import { Response } from 'playwright-core';
4
- import { T as TestOptions$1, b as TestHooks, G as GotoOptions } from './shared/test-utils.DsSnl8Os.mjs';
4
+ import { T as TestOptions$1, G as GotoOptions, b as TestHooks } from './shared/test-utils.DgnIK8xl.mjs';
5
5
  import '@nuxt/schema';
6
6
  import 'tinyexec';
7
7
 
@@ -1,13 +1,14 @@
1
1
  import defu from 'defu';
2
2
  import { test as test$1 } from '@playwright/test';
3
3
  export { expect } from '@playwright/test';
4
- import { d as createTest, w as waitForHydration } from './shared/test-utils.DeQRWngN.mjs';
4
+ import { w as waitForHydration, d as createTest } from './shared/test-utils.BIDY1MqP.mjs';
5
5
  import 'node:path';
6
6
  import 'ufo';
7
+ import 'std-env';
7
8
  import 'consola';
8
9
  import 'node:fs';
9
10
  import '@nuxt/kit';
10
- import { d as url } from './shared/test-utils.JktOT-Lz.mjs';
11
+ import { d as url } from './shared/test-utils.CHPAu7TP.mjs';
11
12
  import 'pathe';
12
13
  import '#dirs';
13
14
  import 'tinyexec';
@@ -15,8 +16,8 @@ import 'get-port-please';
15
16
  import 'ofetch';
16
17
 
17
18
  const test = test$1.extend({
18
- nuxt: [undefined, { option: true, scope: "worker" }],
19
- defaults: [{ nuxt: undefined }, { option: true, scope: "worker" }],
19
+ nuxt: [void 0, { option: true, scope: "worker" }],
20
+ defaults: [{ nuxt: void 0 }, { option: true, scope: "worker" }],
20
21
  _nuxtHooks: [
21
22
  async ({ nuxt, defaults }, use) => {
22
23
  const hooks = createTest(defu(nuxt || {}, defaults.nuxt || {}));
@@ -1,6 +1,6 @@
1
1
  import { EventHandler, HTTPMethod } from 'h3';
2
2
  import { SetupContext, RenderFunction, ComputedOptions, MethodOptions, ComponentOptionsMixin, EmitsOptions, ComponentInjectOptions, ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, ComponentPropsOptions, ComponentOptionsWithObjectProps } from 'vue';
3
- import { mount, ComponentMountingOptions } from '@vue/test-utils';
3
+ import { ComponentMountingOptions, mount } from '@vue/test-utils';
4
4
  import { RouteLocationRaw } from 'vue-router';
5
5
  import * as _testing_library_vue from '@testing-library/vue';
6
6
  import { RenderOptions as RenderOptions$1 } from '@testing-library/vue';
@@ -1,7 +1,7 @@
1
1
  import { defineEventHandler } from 'h3';
2
2
  import { mount } from '@vue/test-utils';
3
- import { reactive, h as h$1, Suspense, nextTick, getCurrentInstance, isReadonly, unref, effectScope } from 'vue';
4
- import { createDefu, defu } from 'defu';
3
+ import { reactive, h as h$1, Suspense, nextTick, getCurrentInstance, unref, isReadonly, defineComponent as defineComponent$1, effectScope } from 'vue';
4
+ import { defu } from 'defu';
5
5
  import { defineComponent, useRouter, h, tryUseNuxtApp } from '#imports';
6
6
  import NuxtRoot from '#build/root-component.mjs';
7
7
 
@@ -10,7 +10,7 @@ function registerEndpoint(url, options) {
10
10
  if (!app) return;
11
11
  const config = typeof options === "function" ? {
12
12
  handler: options,
13
- method: undefined
13
+ method: void 0
14
14
  } : options;
15
15
  app.use("/_" + url, defineEventHandler(config.handler), {
16
16
  match(_, event) {
@@ -106,7 +106,7 @@ async function mountSuspended(component, options) {
106
106
  vm.__setProps = (props2) => {
107
107
  Object.assign(setProps, props2);
108
108
  };
109
- resolve(vm);
109
+ resolve(wrappedMountedWrapper(vm));
110
110
  })
111
111
  },
112
112
  {
@@ -161,10 +161,10 @@ async function mountSuspended(component, options) {
161
161
  }
162
162
  }
163
163
  return render.call(this, renderContext, ...args);
164
- } : undefined,
165
- setup: setup ? (props2) => wrappedSetup(props2, setupContext) : undefined
164
+ } : void 0,
165
+ setup: setup ? (props2) => wrappedSetup(props2, setupContext) : void 0
166
166
  };
167
- return () => h$1(clonedComponent, { ...defuReplaceArray(setProps, props), ...attrs }, slots);
167
+ return () => h$1(clonedComponent, { ...props, ...setProps, ...attrs }, slots);
168
168
  }
169
169
  })
170
170
  }
@@ -174,6 +174,7 @@ async function mountSuspended(component, options) {
174
174
  _options,
175
175
  {
176
176
  slots,
177
+ attrs,
177
178
  global: {
178
179
  config: {
179
180
  globalProperties: vueApp.config.globalProperties
@@ -185,7 +186,7 @@ async function mountSuspended(component, options) {
185
186
  MountSuspendedHelper: false,
186
187
  [component && typeof component === "object" && "name" in component && typeof component.name === "string" ? component.name : "MountSuspendedComponent"]: false
187
188
  },
188
- components: { RouterLink }
189
+ components: { ...vueApp._context.components, RouterLink }
189
190
  }
190
191
  }
191
192
  )
@@ -193,12 +194,6 @@ async function mountSuspended(component, options) {
193
194
  }
194
195
  );
195
196
  }
196
- const defuReplaceArray = createDefu((obj, key, value) => {
197
- if (Array.isArray(obj[key])) {
198
- obj[key] = value;
199
- return true;
200
- }
201
- });
202
197
  function cloneProps$1(props) {
203
198
  const newProps = reactive({});
204
199
  for (const key in props) {
@@ -206,6 +201,27 @@ function cloneProps$1(props) {
206
201
  }
207
202
  return newProps;
208
203
  }
204
+ function wrappedMountedWrapper(wrapper) {
205
+ const proxy = new Proxy(wrapper, {
206
+ get: (target, prop, receiver) => {
207
+ if (prop === "element") {
208
+ const component = target.findComponent({ name: "MountSuspendedComponent" });
209
+ return component[prop];
210
+ } else {
211
+ return Reflect.get(target, prop, receiver);
212
+ }
213
+ }
214
+ });
215
+ for (const key of ["props"]) {
216
+ proxy[key] = new Proxy(wrapper[key], {
217
+ apply: (target, thisArg, args) => {
218
+ const component = thisArg.findComponent({ name: "MountSuspendedComponent" });
219
+ return component[key](...args);
220
+ }
221
+ });
222
+ }
223
+ return proxy;
224
+ }
209
225
 
210
226
  const WRAPPER_EL_ID = "test-wrapper";
211
227
  async function renderSuspended(component, options) {
@@ -234,6 +250,12 @@ async function renderSuspended(component, options) {
234
250
  return result;
235
251
  }
236
252
  };
253
+ const WrapperComponent = defineComponent$1({
254
+ inheritAttrs: false,
255
+ render() {
256
+ return h$1("div", { id: WRAPPER_EL_ID }, this.$slots.default?.());
257
+ }
258
+ });
237
259
  return new Promise((resolve) => {
238
260
  const utils = renderFromTestingLibrary(
239
261
  {
@@ -254,8 +276,7 @@ async function renderSuspended(component, options) {
254
276
  // we add this additional root element because otherwise testing-library breaks
255
277
  // because there's no root element while Suspense is resolving
256
278
  h$1(
257
- "div",
258
- { id: WRAPPER_EL_ID },
279
+ WrapperComponent,
259
280
  h$1(
260
281
  Suspense,
261
282
  {
@@ -312,8 +333,8 @@ async function renderSuspended(component, options) {
312
333
  }
313
334
  }
314
335
  return render.call(this, renderContext, ...args);
315
- } : undefined,
316
- setup: setup ? (props2) => wrappedSetup(props2, setupContext) : undefined
336
+ } : void 0,
337
+ setup: setup ? (props2) => wrappedSetup(props2, setupContext) : void 0
317
338
  };
318
339
  return () => h$1(clonedComponent, { ...props && typeof props === "object" ? props : {}, ...attrs }, slots);
319
340
  }
@@ -325,6 +346,7 @@ async function renderSuspended(component, options) {
325
346
  },
326
347
  defu(_options, {
327
348
  slots,
349
+ attrs,
328
350
  global: {
329
351
  config: {
330
352
  globalProperties: vueApp.config.globalProperties
@@ -1,4 +1,4 @@
1
- import { u as useTestContext, d as url, c as createTestContext, s as setTestContext, b as stopServer, a as startServer } from './test-utils.JktOT-Lz.mjs';
1
+ import { u as useTestContext, d as url, c as createTestContext, a as startServer, b as stopServer, s as setTestContext } from './test-utils.CHPAu7TP.mjs';
2
2
  import { existsSync, promises } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
4
  import { defu } from 'defu';
@@ -127,7 +127,7 @@ async function setupJest(hooks) {
127
127
  test("setup", hooks.setup, hooks.ctx.options.setupTimeout);
128
128
  beforeEach(hooks.beforeEach);
129
129
  afterEach(hooks.afterEach);
130
- afterAll(hooks.afterAll, 2e4);
130
+ afterAll(hooks.afterAll, hooks.ctx.options.teardownTimeout);
131
131
  }
132
132
 
133
133
  async function setupVitest(hooks) {
@@ -136,7 +136,7 @@ async function setupVitest(hooks) {
136
136
  vitest.beforeAll(hooks.setup, hooks.ctx.options.setupTimeout);
137
137
  vitest.beforeEach(hooks.beforeEach);
138
138
  vitest.afterEach(hooks.afterEach);
139
- vitest.afterAll(hooks.afterAll);
139
+ vitest.afterAll(hooks.afterAll, hooks.ctx.options.teardownTimeout);
140
140
  }
141
141
 
142
142
  const setupMaps = {
@@ -150,13 +150,13 @@ function createTest(options) {
150
150
  setTestContext(ctx);
151
151
  };
152
152
  const afterEach = () => {
153
- setTestContext(undefined);
153
+ setTestContext(void 0);
154
154
  };
155
155
  const afterAll = async () => {
156
156
  if (ctx.serverProcess) {
157
157
  setTestContext(ctx);
158
158
  await stopServer();
159
- setTestContext(undefined);
159
+ setTestContext(void 0);
160
160
  }
161
161
  if (ctx.nuxt && ctx.nuxt.options.dev) {
162
162
  await ctx.nuxt.close();
@@ -1,11 +1,11 @@
1
- import { exec } from 'tinyexec';
1
+ import { x } from 'tinyexec';
2
2
  import { getRandomPort, waitForPort } from 'get-port-please';
3
- import { fetch as fetch$1, $fetch as $fetch$1 } from 'ofetch';
4
- import * as _kit from '@nuxt/kit';
3
+ import { $fetch as $fetch$1, fetch as fetch$1 } from 'ofetch';
5
4
  import { resolve as resolve$1 } from 'pathe';
6
5
  import { withTrailingSlash, joinURL } from 'ufo';
7
6
  import { resolve } from 'node:path';
8
7
  import { defu } from 'defu';
8
+ import { isWindows } from 'std-env';
9
9
 
10
10
  let currentContext;
11
11
  function createTestContext(options) {
@@ -13,7 +13,8 @@ function createTestContext(options) {
13
13
  testDir: resolve(process.cwd(), "test"),
14
14
  fixture: "fixture",
15
15
  configFile: "nuxt.config",
16
- setupTimeout: 120 * 1e3,
16
+ setupTimeout: isWindows ? 24e4 : 12e4,
17
+ teardownTimeout: 3e4,
17
18
  dev: !!JSON.parse(process.env.NUXT_TEST_DEV || "false"),
18
19
  logLevel: 1,
19
20
  server: true,
@@ -69,7 +70,6 @@ function exposeContextToEnv() {
69
70
  process.env.NUXT_TEST_CONTEXT = JSON.stringify({ options, browser, url });
70
71
  }
71
72
 
72
- const kit = _kit.default || _kit;
73
73
  async function startServer(options = {}) {
74
74
  const ctx = useTestContext();
75
75
  await stopServer();
@@ -77,8 +77,8 @@ async function startServer(options = {}) {
77
77
  const port = ctx.options.port || await getRandomPort(host);
78
78
  ctx.url = `http://${host}:${port}/`;
79
79
  if (ctx.options.dev) {
80
- const nuxiCLI = await kit.resolvePath("nuxi/cli");
81
- ctx.serverProcess = exec(nuxiCLI, ["_dev"], {
80
+ ctx.serverProcess = x("nuxi", ["_dev"], {
81
+ throwOnError: true,
82
82
  nodeOptions: {
83
83
  cwd: ctx.nuxt.options.rootDir,
84
84
  stdio: "inherit",
@@ -114,10 +114,11 @@ async function startServer(options = {}) {
114
114
  throw lastError || new Error("Timeout waiting for dev server!");
115
115
  } else {
116
116
  const outputDir = ctx.nuxt ? ctx.nuxt.options.nitro.output.dir : ctx.options.nuxtConfig.nitro.output.dir;
117
- ctx.serverProcess = exec(
117
+ ctx.serverProcess = x(
118
118
  "node",
119
119
  [resolve$1(outputDir, "server/index.mjs")],
120
120
  {
121
+ throwOnError: true,
121
122
  nodeOptions: {
122
123
  stdio: "inherit",
123
124
  env: {
@@ -47,9 +47,14 @@ interface TestOptions {
47
47
  dev: boolean;
48
48
  /**
49
49
  * The amount of time (in milliseconds) to allow for `setupTest` to complete its work (which could include building or generating files for a Nuxt application, depending on the options that are passed).
50
- * @default `60000`
50
+ * @default `120000` or `240000` on windows
51
51
  */
52
52
  setupTimeout: number;
53
+ /**
54
+ * The amount of time (in milliseconds) to allow tearing down the test environment, such as closing the browser.
55
+ * @default `30000`
56
+ */
57
+ teardownTimeout: number;
53
58
  waitFor: number;
54
59
  /**
55
60
  * Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite.
@@ -33,9 +33,9 @@ const jsdom = (async function(global, { jsdom = {} }) {
33
33
  });
34
34
  const window = new JSDOM(jsdomOptions.html, {
35
35
  ...jsdomOptions,
36
- resources: jsdomOptions.resources ?? (jsdomOptions.userAgent ? new ResourceLoader({ userAgent: jsdomOptions.userAgent }) : undefined),
37
- virtualConsole: jsdomOptions.console && global.console ? new VirtualConsole().sendTo(global.console) : undefined,
38
- cookieJar: jsdomOptions.cookieJar ? new CookieJar() : undefined
36
+ resources: jsdomOptions.resources ?? (jsdomOptions.userAgent ? new ResourceLoader({ userAgent: jsdomOptions.userAgent }) : void 0),
37
+ virtualConsole: jsdomOptions.console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
38
+ cookieJar: jsdomOptions.cookieJar ? new CookieJar() : void 0
39
39
  }).window;
40
40
  window.scrollTo = () => {
41
41
  };
@@ -135,34 +135,25 @@ const index = {
135
135
  "builds"
136
136
  );
137
137
  const manifestBaseRoutePath = joinURL("/_", manifestOutputPath);
138
+ const buildId = win.__NUXT__.config.app.buildId || "test";
138
139
  h3App.use(
139
140
  `${manifestBaseRoutePath}/latest.json`,
140
141
  defineEventHandler(() => ({
141
- id: "test",
142
+ id: buildId,
142
143
  timestamp
143
144
  }))
144
145
  );
145
146
  h3App.use(
146
- `${manifestBaseRoutePath}/meta/test.json`,
147
+ `${manifestBaseRoutePath}/meta/${buildId}.json`,
147
148
  defineEventHandler(() => ({
148
- id: "test",
149
- timestamp,
150
- matcher,
151
- prerendered: []
152
- }))
153
- );
154
- h3App.use(
155
- `${manifestBaseRoutePath}/meta/dev.json`,
156
- defineEventHandler(() => ({
157
- id: "test",
149
+ id: buildId,
158
150
  timestamp,
159
151
  matcher,
160
152
  prerendered: []
161
153
  }))
162
154
  );
163
155
  registry.add(`${manifestOutputPath}/latest.json`);
164
- registry.add(`${manifestOutputPath}/meta/test.json`);
165
- registry.add(`${manifestOutputPath}/meta/dev.json`);
156
+ registry.add(`${manifestOutputPath}/meta/${buildId}.json`);
166
157
  return {
167
158
  // called after all tests with this env have been run
168
159
  teardown() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/test-utils",
3
- "version": "3.15.3",
3
+ "version": "3.16.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/test-utils.git"
@@ -8,7 +8,6 @@
8
8
  "description": "Test utilities for Nuxt",
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "types": "./dist/e2e.d.ts",
12
11
  "exports": {
13
12
  ".": "./dist/e2e.mjs",
14
13
  "./config": "./dist/config.mjs",
@@ -22,43 +21,63 @@
22
21
  "imports": {
23
22
  "#dirs": "./dirs.js"
24
23
  },
24
+ "typesVersions": {
25
+ "*": {
26
+ ".": [
27
+ "./dist/e2e.d.mts"
28
+ ],
29
+ "config": [
30
+ "./dist/config.d.mts"
31
+ ],
32
+ "e2e": [
33
+ "./dist/e2e.d.mts"
34
+ ],
35
+ "playwright": [
36
+ "./dist/playwright.d.mts"
37
+ ],
38
+ "experimental": [
39
+ "./dist/experimental.d.mts"
40
+ ],
41
+ "module": [
42
+ "./dist/module.d.mts"
43
+ ],
44
+ "runtime": [
45
+ "./dist/runtime-utils/index.d.mts"
46
+ ],
47
+ "vitest-environment": [
48
+ "./dist/vitest-environment.d.mts"
49
+ ]
50
+ }
51
+ },
25
52
  "files": [
26
53
  "dist",
27
- "dirs.js",
28
- "config.d.ts",
29
- "e2e.d.ts",
30
- "experimental.d.ts",
31
- "module.d.ts",
32
- "playwright.d.ts",
33
- "runtime.d.ts",
34
- "vitest-environment.d.ts"
54
+ "dirs.js"
35
55
  ],
36
56
  "scripts": {
37
57
  "lint": "eslint .",
38
58
  "lint:fix": "eslint . --fix",
39
- "test:examples": "pnpm -r test --filter !example-app-cucumber --filter !example-app-jest && pnpm -r test --filter example-app-cucumber",
59
+ "test:examples": "pnpm --filter '!example-app-cucumber' --filter '!example-app-jest' -r test && pnpm --filter example-app-cucumber -r test",
40
60
  "test:types": "vue-tsc --noEmit",
41
61
  "test:unit": "vitest test/unit --run",
42
62
  "prepack": "unbuild",
43
- "dev:prepare": "nuxi prepare && unbuild --stub && pnpm -r dev:prepare",
44
- "release": "pnpm prepack && pnpm test:examples && changelogen --release --push"
63
+ "dev:prepare": "nuxi prepare && unbuild --stub && pnpm -r dev:prepare"
45
64
  },
46
65
  "dependencies": {
47
- "@nuxt/kit": "^3.15.1",
48
- "@nuxt/schema": "^3.15.1",
49
- "c12": "^2.0.1",
50
- "consola": "^3.3.3",
66
+ "@nuxt/kit": "^3.15.4",
67
+ "@nuxt/schema": "^3.15.4",
68
+ "c12": "^2.0.2",
69
+ "consola": "^3.4.0",
51
70
  "defu": "^6.1.4",
52
71
  "destr": "^2.0.3",
53
72
  "estree-walker": "^3.0.3",
54
73
  "fake-indexeddb": "^6.0.0",
55
74
  "get-port-please": "^3.1.2",
56
- "h3": "^1.13.1",
75
+ "h3": "^1.15.0",
57
76
  "local-pkg": "^1.0.0",
58
77
  "magic-string": "^0.30.17",
59
- "node-fetch-native": "^1.6.4",
78
+ "node-fetch-native": "^1.6.5",
60
79
  "ofetch": "^1.4.1",
61
- "pathe": "^2.0.1",
80
+ "pathe": "^2.0.3",
62
81
  "perfect-debounce": "^1.0.0",
63
82
  "radix3": "^1.1.2",
64
83
  "scule": "^1.3.0",
@@ -66,39 +85,40 @@
66
85
  "tinyexec": "^0.3.2",
67
86
  "ufo": "^1.5.4",
68
87
  "unenv": "^1.10.0",
69
- "unplugin": "^2.1.2",
70
- "vite": "^6.0.7",
88
+ "unplugin": "^2.2.0",
89
+ "vite": "^6.1.1",
71
90
  "vitest-environment-nuxt": "^1.0.1",
72
91
  "vue": "^3.5.13"
73
92
  },
74
93
  "devDependencies": {
75
94
  "@cucumber/cucumber": "11.2.0",
76
95
  "@jest/globals": "29.7.0",
77
- "@nuxt/devtools-kit": "1.7.0",
78
- "@nuxt/eslint-config": "0.7.5",
79
- "@playwright/test": "1.49.1",
96
+ "@nuxt/devtools-kit": "2.1.0",
97
+ "@nuxt/eslint-config": "1.1.0",
98
+ "@playwright/test": "1.50.1",
80
99
  "@testing-library/vue": "8.1.0",
81
100
  "@types/estree": "1.0.6",
82
101
  "@types/jsdom": "21.1.7",
102
+ "@types/node": "22.13.4",
83
103
  "@types/semver": "7.5.8",
84
104
  "@vue/test-utils": "2.4.6",
85
105
  "changelogen": "0.5.7",
86
106
  "compatx": "0.1.8",
87
- "eslint": "9.18.0",
107
+ "eslint": "9.20.1",
88
108
  "installed-check": "9.3.0",
89
- "jiti": "2.4.2",
90
- "knip": "5.42.0",
109
+ "knip": "5.44.4",
91
110
  "nitropack": "2.10.4",
92
- "nuxt": "3.15.1",
93
- "playwright-core": "1.49.1",
94
- "rollup": "4.30.1",
95
- "semver": "7.6.3",
96
- "typescript": "5.7.2",
111
+ "nuxt": "3.15.4",
112
+ "pkg-pr-new": "0.0.39",
113
+ "playwright-core": "1.50.1",
114
+ "rollup": "4.34.8",
115
+ "semver": "7.7.1",
116
+ "typescript": "5.7.3",
97
117
  "unbuild": "latest",
98
- "unimport": "3.14.5",
99
- "vitest": "2.1.8",
118
+ "unimport": "4.1.2",
119
+ "vitest": "3.0.6",
100
120
  "vue-router": "4.5.0",
101
- "vue-tsc": "2.2.0"
121
+ "vue-tsc": "2.2.2"
102
122
  },
103
123
  "peerDependencies": {
104
124
  "@cucumber/cucumber": "^10.3.1 || ^11.0.0",
@@ -106,10 +126,10 @@
106
126
  "@playwright/test": "^1.43.1",
107
127
  "@testing-library/vue": "^7.0.0 || ^8.0.1",
108
128
  "@vue/test-utils": "^2.4.2",
109
- "happy-dom": "^9.10.9 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
129
+ "happy-dom": "^9.10.9 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
110
130
  "jsdom": "^22.0.0 || ^23.0.0 || ^24.0.0 || ^25.0.0 || ^26.0.0",
111
131
  "playwright-core": "^1.43.1",
112
- "vitest": "^0.34.6 || ^1.0.0 || ^2.0.0 || ^3.0.0-beta.3"
132
+ "vitest": "^0.34.6 || ^1.0.0 || ^2.0.0 || ^3.0.0"
113
133
  },
114
134
  "peerDependenciesMeta": {
115
135
  "@cucumber/cucumber": {
@@ -146,17 +166,17 @@
146
166
  "resolutions": {
147
167
  "@cucumber/cucumber": "11.2.0",
148
168
  "@nuxt/devtools": "1.0.8",
149
- "@nuxt/kit": "^3.15.1",
150
- "@nuxt/schema": "^3.15.1",
169
+ "@nuxt/kit": "^3.15.4",
170
+ "@nuxt/schema": "^3.15.4",
151
171
  "@nuxt/test-utils": "workspace:*",
152
- "rollup": "4.30.1",
153
- "vite": "6.0.7",
154
- "vite-node": "2.1.8",
155
- "vitest": "2.1.8",
172
+ "rollup": "4.34.8",
173
+ "vite": "^6.1.1",
174
+ "vite-node": "3.0.6",
175
+ "vitest": "3.0.6",
156
176
  "vue": "^3.5.13"
157
177
  },
158
178
  "engines": {
159
179
  "node": "^18.20.5 || ^20.9.0 || ^22.0.0 || >=23.0.0"
160
180
  },
161
- "packageManager": "pnpm@9.15.3"
181
+ "packageManager": "pnpm@10.4.1"
162
182
  }
package/config.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/config'
package/dist/config.d.ts DELETED
@@ -1,64 +0,0 @@
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/node';
5
- import { DotenvOptions } from 'c12';
6
-
7
- interface GetVitestConfigOptions {
8
- nuxt: Nuxt;
9
- viteConfig: InlineConfig;
10
- }
11
- interface LoadNuxtOptions {
12
- dotenv?: Partial<DotenvOptions>;
13
- overrides?: Partial<NuxtConfig>;
14
- }
15
- declare function getVitestConfigFromNuxt(options?: GetVitestConfigOptions, loadNuxtOptions?: LoadNuxtOptions): Promise<InlineConfig & {
16
- test: InlineConfig$1;
17
- }>;
18
- declare function defineVitestConfig(config?: InlineConfig & {
19
- test?: InlineConfig$1;
20
- }): vite.UserConfig & Promise<vite.UserConfig> & vite.UserConfigFnObject & vite.UserConfigFnPromise & vite.UserConfigFn;
21
- interface NuxtEnvironmentOptions {
22
- rootDir?: string;
23
- /**
24
- * The starting URL for your Nuxt window environment
25
- * @default {http://localhost:3000}
26
- */
27
- url?: string;
28
- /**
29
- * You can define how environment options are read when loading the Nuxt configuration.
30
- */
31
- dotenv?: Partial<DotenvOptions>;
32
- /**
33
- * Configuration that will override the values in your `nuxt.config` file.
34
- */
35
- overrides?: NuxtConfig;
36
- /**
37
- * The id of the root div to which the app should be mounted. You should also set `app.rootId` to the same value.
38
- * @default {nuxt-test}
39
- */
40
- rootId?: string;
41
- /**
42
- * The name of the DOM environment to use.
43
- *
44
- * It also needs to be installed as a dev dependency in your project.
45
- * @default {happy-dom}
46
- */
47
- domEnvironment?: 'happy-dom' | 'jsdom';
48
- mock?: {
49
- intersectionObserver?: boolean;
50
- indexedDb?: boolean;
51
- };
52
- }
53
- declare module 'vitest/node' {
54
- interface EnvironmentOptions {
55
- nuxt?: NuxtEnvironmentOptions;
56
- }
57
- }
58
- declare module 'vitest' {
59
- interface EnvironmentOptions {
60
- nuxt?: NuxtEnvironmentOptions;
61
- }
62
- }
63
-
64
- export { defineVitestConfig, getVitestConfigFromNuxt };
package/dist/e2e.d.ts DELETED
@@ -1,45 +0,0 @@
1
- import { T as TestOptions, a as TestContext, b as TestHooks } from './shared/test-utils.DsSnl8Os.js';
2
- export { $ as $fetch, G as GotoOptions, N as NuxtPage, S as StartServerOptions, h as TestRunner, c as createBrowser, d as createPage, f as fetch, g as getBrowser, s as startServer, e as stopServer, u as url, w as waitForHydration } from './shared/test-utils.DsSnl8Os.js';
3
- import { LogType } from 'consola';
4
- import 'playwright-core';
5
- import '@nuxt/schema';
6
- import 'tinyexec';
7
-
8
- declare function createTestContext(options: Partial<TestOptions>): TestContext;
9
- declare function useTestContext(): TestContext;
10
- declare function setTestContext(context: TestContext): TestContext;
11
- declare function setTestContext(context?: TestContext): TestContext | undefined;
12
- declare function isDev(): boolean;
13
- declare function recoverContextFromEnv(): void;
14
- declare function exposeContextToEnv(): void;
15
-
16
- declare function mockFn(): ((...args: unknown[]) => unknown) | undefined;
17
- declare function mockLogger(): Record<LogType, (...args: unknown[]) => void>;
18
-
19
- declare function loadFixture(): Promise<void>;
20
- declare function buildFixture(): Promise<void>;
21
-
22
- declare function setupCucumber(hooks: TestHooks): Promise<void>;
23
-
24
- declare function setupJest(hooks: TestHooks): Promise<void>;
25
-
26
- declare function setupVitest(hooks: TestHooks): Promise<void>;
27
-
28
- declare const setupMaps: {
29
- cucumber: typeof setupCucumber;
30
- jest: typeof setupJest;
31
- vitest: typeof setupVitest;
32
- };
33
- declare function createTest(options: Partial<TestOptions>): TestHooks;
34
- declare function setup(options?: Partial<TestOptions>): Promise<void>;
35
-
36
- interface RunTestOptions {
37
- rootDir: string;
38
- dev?: boolean;
39
- watch?: boolean;
40
- runner?: 'vitest';
41
- globalSetup?: boolean;
42
- }
43
- declare function runTests(opts: RunTestOptions): Promise<void>;
44
-
45
- export { type RunTestOptions, TestContext, TestHooks, TestOptions, buildFixture, createTest, createTestContext, exposeContextToEnv, isDev, loadFixture, mockFn, mockLogger, recoverContextFromEnv, runTests, setTestContext, setup, setupMaps, useTestContext };
@@ -1,7 +0,0 @@
1
- /**
2
- * This is a function to render a component directly with the Nuxt server.
3
- */
4
- declare function $fetchComponent(filepath: string, props?: Record<string, unknown>): Promise<unknown>;
5
- declare function componentTestUrl(filepath: string, props?: Record<string, unknown>): string;
6
-
7
- export { $fetchComponent, componentTestUrl };
package/dist/module.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { UserConfig } from 'vitest/node';
3
-
4
- interface NuxtVitestOptions {
5
- startOnBoot?: boolean;
6
- logToConsole?: boolean;
7
- vitestConfig?: UserConfig;
8
- }
9
- declare const _default: _nuxt_schema.NuxtModule<NuxtVitestOptions, NuxtVitestOptions, false>;
10
-
11
- export { type NuxtVitestOptions, _default as default };
@@ -1,38 +0,0 @@
1
- import * as _playwright_test from '@playwright/test';
2
- export { expect } from '@playwright/test';
3
- import { Response } from 'playwright-core';
4
- import { T as TestOptions$1, b as TestHooks, G as GotoOptions } from './shared/test-utils.DsSnl8Os.js';
5
- import '@nuxt/schema';
6
- import 'tinyexec';
7
-
8
- type ConfigOptions = {
9
- nuxt: Partial<TestOptions$1> | undefined;
10
- defaults: {
11
- nuxt: Partial<TestOptions$1> | undefined;
12
- };
13
- };
14
- type WorkerOptions = {
15
- _nuxtHooks: TestHooks;
16
- };
17
- type TestOptions = {
18
- goto: (url: string, options?: GotoOptions) => Promise<Response | null>;
19
- };
20
- /**
21
- * Use a preconfigured Nuxt fixture.
22
- *
23
- * You can pass a `nuxt: {}` object in your device configuration, in the `use` key of your config file,
24
- * or use the following syntax within your test file to configure your Nuxt fixture:
25
- *
26
- ```ts
27
- test.use({
28
- nuxt: {
29
- rootDir: fileURLToPath(new URL('.', import.meta.url)),
30
- }
31
- })
32
- ```
33
- *
34
- * In `playwright.config.ts` you can pass `defaults: { nuxt: {} }` object for merging with test.use nuxt options
35
- */
36
- declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & TestOptions, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & WorkerOptions & ConfigOptions>;
37
-
38
- export { type ConfigOptions, test };
@@ -1,159 +0,0 @@
1
- import { EventHandler, HTTPMethod } from 'h3';
2
- import { SetupContext, RenderFunction, ComputedOptions, MethodOptions, ComponentOptionsMixin, EmitsOptions, ComponentInjectOptions, ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, ComponentPropsOptions, ComponentOptionsWithObjectProps } from 'vue';
3
- import { mount, ComponentMountingOptions } from '@vue/test-utils';
4
- import { RouteLocationRaw } from 'vue-router';
5
- import * as _testing_library_vue from '@testing-library/vue';
6
- import { RenderOptions as RenderOptions$1 } from '@testing-library/vue';
7
-
8
- type Awaitable<T> = T | Promise<T>;
9
- type OptionalFunction<T> = T | (() => Awaitable<T>);
10
- /**
11
- * `registerEndpoint` allows you create Nitro endpoint that returns mocked data. It can come in handy if you want to test a component that makes requests to API to display some data.
12
- * @param url - endpoint name (e.g. `/test/`).
13
- * @param options - factory function that returns the mocked data or an object containing both the `handler` and the `method` properties.
14
- * @example
15
- * ```ts
16
- * import { registerEndpoint } from '@nuxt/test-utils/runtime'
17
- *
18
- * registerEndpoint("/test/", () => {
19
- * test: "test-field"
20
- * })
21
- * ```
22
- * @see https://nuxt.com/docs/getting-started/testing#registerendpoint
23
- */
24
- declare function registerEndpoint(url: string, options: EventHandler | {
25
- handler: EventHandler;
26
- method: HTTPMethod;
27
- }): void;
28
- /**
29
- * `mockNuxtImport` allows you to mock Nuxt's auto import functionality.
30
- * @param _name - name of an import to mock.
31
- * @param _factory - factory function that returns mocked import.
32
- * @example
33
- * ```ts
34
- * import { mockNuxtImport } from '@nuxt/test-utils/runtime'
35
- *
36
- * mockNuxtImport('useStorage', () => {
37
- * return () => {
38
- * return { value: 'mocked storage' }
39
- * }
40
- * })
41
- * ```
42
- * @see https://nuxt.com/docs/getting-started/testing#mocknuxtimport
43
- */
44
- declare function mockNuxtImport<T = unknown>(_name: string, _factory: () => T | Promise<T>): void;
45
- /**
46
- * `mockComponent` allows you to mock Nuxt's component.
47
- * @param path - component name in PascalCase, or the relative path of the component.
48
- * @param setup - factory function that returns the mocked component.
49
- * @example
50
- * ```ts
51
- * import { mockComponent } from '@nuxt/test-utils/runtime'
52
- *
53
- * mockComponent('MyComponent', {
54
- * props: {
55
- * value: String
56
- * },
57
- * setup(props) {
58
- * // ...
59
- * }
60
- * })
61
- *
62
- * // relative path or alias also works
63
- * mockComponent('~/components/my-component.vue', async () => {
64
- * // or a factory function
65
- * return {
66
- * setup(props) {
67
- * // ...
68
- * }
69
- * }
70
- * })
71
- *
72
- * // or you can use SFC for redirecting to a mock component
73
- * mockComponent('MyComponent', () => import('./MockComponent.vue'))
74
- * ```
75
- * @see https://nuxt.com/docs/getting-started/testing#mockcomponent
76
- */
77
- declare function mockComponent<Props, RawBindings = object>(path: string, setup: OptionalFunction<(props: Readonly<Props>, ctx: SetupContext) => RawBindings | RenderFunction>): void;
78
- declare function mockComponent<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string>(path: string, options: OptionalFunction<ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II>>): void;
79
- declare function mockComponent<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string>(path: string, options: OptionalFunction<ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II>>): void;
80
- declare function mockComponent<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string>(path: string, options: OptionalFunction<ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II>>): void;
81
-
82
- type MountSuspendedOptions<T> = ComponentMountingOptions<T> & {
83
- route?: RouteLocationRaw;
84
- };
85
- type SetupState$1 = Record<string, any>;
86
- /**
87
- * `mountSuspended` allows you to mount any vue component within the Nuxt environment, allowing async setup and access to injections from your Nuxt plugins. For example:
88
- *
89
- * ```ts
90
- * // tests/components/SomeComponents.nuxt.spec.ts
91
- * it('can mount some component', async () => {
92
- * const component = await mountSuspended(SomeComponent)
93
- * expect(component.text()).toMatchInlineSnapshot(
94
- * 'This is an auto-imported component'
95
- * )
96
- * })
97
- *
98
- * // tests/App.nuxt.spec.ts
99
- * it('can also mount an app', async () => {
100
- * const component = await mountSuspended(App, { route: '/test' })
101
- * expect(component.html()).toMatchInlineSnapshot(`
102
- * "<div>This is an auto-imported component</div>
103
- * <div> I am a global component </div>
104
- * <div>/</div>
105
- * <a href=\\"/test\\"> Test link </a>"
106
- * `)
107
- * })
108
- * ```
109
- * @param component the component to be tested
110
- * @param options optional options to set up your component
111
- */
112
- declare function mountSuspended<T>(component: T, options?: MountSuspendedOptions<T>): Promise<ReturnType<typeof mount<T>> & {
113
- setupState: SetupState$1;
114
- }>;
115
-
116
- type RenderOptions<C = unknown> = RenderOptions$1<C> & {
117
- route?: RouteLocationRaw;
118
- };
119
- type SetupState = Record<string, any>;
120
- /**
121
- * `renderSuspended` allows you to mount any vue component within the Nuxt environment, allowing async setup and access to injections from your Nuxt plugins.
122
- *
123
- * This is a wrapper around the `render` function from @testing-libary/vue, and should be used together with
124
- * utilities from that package.
125
- *
126
- * ```ts
127
- * // tests/components/SomeComponents.nuxt.spec.ts
128
- * import { renderSuspended } from '@nuxt/test-utils/runtime'
129
- *
130
- * it('can render some component', async () => {
131
- * const { html } = await renderSuspended(SomeComponent)
132
- * expect(html()).toMatchInlineSnapshot(
133
- * 'This is an auto-imported component'
134
- * )
135
- *
136
- * })
137
- *
138
- * // tests/App.nuxt.spec.ts
139
- * import { renderSuspended } from '@nuxt/test-utils/runtime'
140
- * import { screen } from '@testing-library/vue'
141
- *
142
- * it('can also mount an app', async () => {
143
- * const { html } = await renderSuspended(App, { route: '/test' })
144
- * expect(screen.getByRole('link', { name: 'Test Link' })).toBeVisible()
145
- * })
146
- * ```
147
- * @param component the component to be tested
148
- * @param options optional options to set up your component
149
- */
150
- declare function renderSuspended<T>(component: T, options?: RenderOptions<T>): Promise<_testing_library_vue.RenderResult & {
151
- setupState: SetupState;
152
- }>;
153
- declare global {
154
- interface Window {
155
- __cleanup?: Array<() => void>;
156
- }
157
- }
158
-
159
- export { mockComponent, mockNuxtImport, mountSuspended, registerEndpoint, renderSuspended };
@@ -1,109 +0,0 @@
1
- import { Browser, Page, Response as Response$1, BrowserContextOptions, LaunchOptions } from 'playwright-core';
2
- import { NuxtConfig, Nuxt } from '@nuxt/schema';
3
- import { exec } from 'tinyexec';
4
-
5
- declare function createBrowser(): Promise<void>;
6
- declare function getBrowser(): Promise<Browser>;
7
- type _GotoOptions = NonNullable<Parameters<Page['goto']>[1]>;
8
- interface GotoOptions extends Omit<_GotoOptions, 'waitUntil'> {
9
- waitUntil?: 'hydration' | 'route' | _GotoOptions['waitUntil'];
10
- }
11
- interface NuxtPage extends Omit<Page, 'goto'> {
12
- goto: (url: string, options?: GotoOptions) => Promise<Response$1 | null>;
13
- }
14
- declare function createPage(path?: string, options?: BrowserContextOptions): Promise<NuxtPage>;
15
- declare function waitForHydration(page: Page, url: string, waitUntil?: GotoOptions['waitUntil']): Promise<void>;
16
-
17
- interface StartServerOptions {
18
- env?: Record<string, unknown>;
19
- }
20
- declare function startServer(options?: StartServerOptions): Promise<void>;
21
- declare function stopServer(): Promise<void>;
22
- declare function fetch(path: string, options?: RequestInit): Promise<Response>;
23
- declare const $fetch: (typeof globalThis)["$fetch"];
24
- declare function url(path: string): string;
25
-
26
- type TestRunner = 'vitest' | 'jest' | 'cucumber';
27
- interface TestOptions {
28
- testDir: string;
29
- fixture: string;
30
- /**
31
- * Name of the configuration file.
32
- * @default `'nuxt.config`
33
- */
34
- configFile: string;
35
- /**
36
- * Path to a directory with a Nuxt app to be put under test.
37
- * @default `'.'`
38
- */
39
- rootDir: string;
40
- buildDir: string;
41
- nuxtConfig: NuxtConfig;
42
- /**
43
- * Whether to run a separate build step.
44
- * @default `true` (`false` if `browser` or `server` is disabled, or if a `host` is provided)
45
- */
46
- build: boolean;
47
- dev: boolean;
48
- /**
49
- * The amount of time (in milliseconds) to allow for `setupTest` to complete its work (which could include building or generating files for a Nuxt application, depending on the options that are passed).
50
- * @default `60000`
51
- */
52
- setupTimeout: number;
53
- waitFor: number;
54
- /**
55
- * Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite.
56
- * @default `false`
57
- */
58
- browser: boolean;
59
- /**
60
- * Specify the runner for the test suite. One of `'vitest' | 'jest' | 'cucumber'`.
61
- * @default `vitest`
62
- */
63
- runner: TestRunner;
64
- logLevel: number;
65
- browserOptions: {
66
- /** The type of browser to launch - either `chromium`, `firefox` or `webkit` */
67
- type: 'chromium' | 'firefox' | 'webkit';
68
- /** `object` of options that will be passed to playwright when launching the browser. See [full API reference](https://playwright.dev/docs/api/class-browsertype#browser-type-launch). */
69
- launch?: LaunchOptions;
70
- };
71
- /**
72
- * Whether to launch a server to respond to requests in the test suite.
73
- * @default `true` (`false` if a `host` is provided)
74
- */
75
- server: boolean;
76
- /**
77
- * If provided, a URL to use as the test target instead of building and running a new server. Useful for running "real" end-to-end tests against a deployed version of your application, or against an already running local server.
78
- * @default `undefined`
79
- */
80
- host?: string;
81
- /**
82
- * If provided, set the launched test server port to the value.
83
- * @default `undefined`
84
- */
85
- port?: number;
86
- env?: StartServerOptions['env'];
87
- }
88
- interface TestContext {
89
- options: TestOptions;
90
- nuxt?: Nuxt;
91
- browser?: Browser;
92
- url?: string;
93
- serverProcess?: ReturnType<typeof exec>;
94
- mockFn?: (...args: unknown[]) => unknown;
95
- /**
96
- * Functions to run on the vitest `afterAll` hook.
97
- * Useful for removing anything created during the test.
98
- */
99
- teardown?: (() => void)[];
100
- }
101
- interface TestHooks {
102
- beforeEach: () => void;
103
- afterEach: () => void;
104
- afterAll: () => Promise<void>;
105
- setup: () => Promise<void>;
106
- ctx: TestContext;
107
- }
108
-
109
- export { $fetch as $, type GotoOptions as G, type NuxtPage as N, type StartServerOptions as S, type TestOptions as T, type TestContext as a, type TestHooks as b, createBrowser as c, createPage as d, stopServer as e, fetch as f, getBrowser as g, type TestRunner as h, startServer as s, url as u, waitForHydration as w };
@@ -1,28 +0,0 @@
1
- import { Environment } from 'vitest/environments';
2
- import { App } from 'h3';
3
- import { $Fetch } from 'nitropack';
4
- import { JSDOMOptions, HappyDOMOptions } from 'vitest/node';
5
-
6
- declare const _default: Environment;
7
-
8
- type NuxtBuiltinEnvironment = 'happy-dom' | 'jsdom';
9
- interface NuxtWindow extends Window {
10
- __app: App;
11
- __registry: Set<string>;
12
- __NUXT_VITEST_ENVIRONMENT__?: boolean;
13
- __NUXT__: Record<string, unknown>;
14
- $fetch: $Fetch;
15
- fetch: ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>);
16
- IntersectionObserver: unknown;
17
- Headers: typeof Headers;
18
- }
19
- interface EnvironmentNuxtOptions {
20
- jsdom?: JSDOMOptions;
21
- happyDom?: HappyDOMOptions;
22
- }
23
- type EnvironmentNuxt = (global: typeof globalThis, options: EnvironmentNuxtOptions) => Promise<{
24
- window: NuxtWindow;
25
- teardown(): void;
26
- }>;
27
-
28
- export { type EnvironmentNuxt, type EnvironmentNuxtOptions, type NuxtBuiltinEnvironment, type NuxtWindow, _default as default };
package/e2e.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/e2e'
package/experimental.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/experimental'
package/module.d.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from './dist/module'
package/playwright.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/playwright'
package/runtime.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/runtime-utils/index.mjs'
@@ -1 +0,0 @@
1
- export { default } from './dist/vitest-environment'