@nuxt/test-utils 3.17.0 → 3.17.2

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.
@@ -136,7 +136,11 @@ async function mountSuspended(component, options) {
136
136
  render: render ? function(_ctx, ...args) {
137
137
  const currentInstance = getCurrentInstance();
138
138
  if (currentInstance) {
139
- currentInstance.emit = setupContext.emit;
139
+ const oldEmit = currentInstance.emit;
140
+ currentInstance.emit = (event, ...args2) => {
141
+ oldEmit(event, ...args2);
142
+ setupContext.emit(event, ...args2);
143
+ };
140
144
  }
141
145
  if (data && typeof data === "function") {
142
146
  const dataObject = data();
@@ -1,11 +1,11 @@
1
- import { createFetch as createFetch$1 } from 'ofetch';
1
+ import { createFetch } from 'ofetch';
2
2
  import { indexedDB } from 'fake-indexeddb';
3
3
  import { joinURL } from 'ufo';
4
- import { createApp, toNodeListener, defineEventHandler } from 'h3';
4
+ import { createApp, toNodeListener, defineEventHandler, splitCookiesString } from 'h3';
5
5
  import defu from 'defu';
6
6
  import { toRouteMatcher, createRouter, exportMatcher } from 'radix3';
7
7
  import { populateGlobal } from 'vitest/environments';
8
- import { createCall, createFetch } from 'unenv/runtime/fetch/index';
8
+ import { fetchNodeRequestHandler } from 'node-mock-http';
9
9
  import { importModule } from 'local-pkg';
10
10
 
11
11
  const happyDom = (async function(_, { happyDom = {} }) {
@@ -103,22 +103,22 @@ const index = {
103
103
  await import('node-fetch-native/polyfill');
104
104
  win.URLSearchParams = globalThis.URLSearchParams;
105
105
  }
106
- const localCall = createCall(toNodeListener(h3App));
107
- const localFetch = createFetch(localCall, win.fetch);
106
+ const nodeHandler = toNodeListener(h3App);
108
107
  const registry = /* @__PURE__ */ new Set();
109
- win.fetch = (init, options) => {
110
- if (typeof init === "string") {
111
- const base = init.split("?")[0];
112
- if (registry.has(base) || registry.has(init)) {
113
- init = "/_" + init;
108
+ win.fetch = async (url2, init) => {
109
+ if (typeof url2 === "string") {
110
+ const base = url2.split("?")[0];
111
+ if (registry.has(base) || registry.has(url2)) {
112
+ url2 = "/_" + url2;
113
+ }
114
+ if (url2.startsWith("/")) {
115
+ const response = await fetchNodeRequestHandler(nodeHandler, url2, init);
116
+ return normalizeFetchResponse(response);
114
117
  }
115
118
  }
116
- return localFetch(init.toString(), {
117
- ...options,
118
- headers: Array.isArray(options?.headers) ? new Headers(options?.headers) : options?.headers
119
- });
119
+ return fetch(url2, init);
120
120
  };
121
- win.$fetch = createFetch$1({ fetch: win.fetch, Headers: win.Headers });
121
+ win.$fetch = createFetch({ fetch: win.fetch, Headers: win.Headers });
122
122
  win.__registry = registry;
123
123
  win.__app = h3App;
124
124
  const { keys, originals } = populateGlobal(global, win, {
@@ -165,5 +165,34 @@ const index = {
165
165
  };
166
166
  }
167
167
  };
168
+ function normalizeFetchResponse(response) {
169
+ if (!response.headers.has("set-cookie")) {
170
+ return response;
171
+ }
172
+ return new Response(response.body, {
173
+ status: response.status,
174
+ statusText: response.statusText,
175
+ headers: normalizeCookieHeaders(response.headers)
176
+ });
177
+ }
178
+ function normalizeCookieHeader(header = "") {
179
+ return splitCookiesString(joinHeaders(header));
180
+ }
181
+ function normalizeCookieHeaders(headers) {
182
+ const outgoingHeaders = new Headers();
183
+ for (const [name, header] of headers) {
184
+ if (name === "set-cookie") {
185
+ for (const cookie of normalizeCookieHeader(header)) {
186
+ outgoingHeaders.append("set-cookie", cookie);
187
+ }
188
+ } else {
189
+ outgoingHeaders.set(name, joinHeaders(header));
190
+ }
191
+ }
192
+ return outgoingHeaders;
193
+ }
194
+ function joinHeaders(value) {
195
+ return Array.isArray(value) ? value.join(", ") : String(value);
196
+ }
168
197
 
169
198
  export { index as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/test-utils",
3
- "version": "3.17.0",
3
+ "version": "3.17.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/test-utils.git"
@@ -63,62 +63,62 @@
63
63
  "dev:prepare": "nuxi prepare && unbuild --stub && pnpm -r dev:prepare"
64
64
  },
65
65
  "dependencies": {
66
- "@nuxt/kit": "^3.15.4",
67
- "@nuxt/schema": "^3.15.4",
68
- "c12": "^2.0.2",
66
+ "@nuxt/kit": "^3.16.0",
67
+ "@nuxt/schema": "^3.16.0",
68
+ "c12": "^3.0.2",
69
69
  "consola": "^3.4.0",
70
70
  "defu": "^6.1.4",
71
71
  "destr": "^2.0.3",
72
72
  "estree-walker": "^3.0.3",
73
73
  "fake-indexeddb": "^6.0.0",
74
74
  "get-port-please": "^3.1.2",
75
- "h3": "^1.15.0",
76
- "local-pkg": "^1.0.0",
75
+ "h3": "^1.15.1",
76
+ "local-pkg": "^1.1.1",
77
77
  "magic-string": "^0.30.17",
78
78
  "node-fetch-native": "^1.6.5",
79
+ "node-mock-http": "^1.0.0",
79
80
  "ofetch": "^1.4.1",
80
81
  "pathe": "^2.0.3",
81
82
  "perfect-debounce": "^1.0.0",
82
83
  "radix3": "^1.1.2",
83
84
  "scule": "^1.3.0",
84
- "std-env": "^3.8.0",
85
+ "std-env": "^3.8.1",
85
86
  "tinyexec": "^0.3.2",
86
87
  "ufo": "^1.5.4",
87
- "unenv": "^1.10.0",
88
88
  "unplugin": "^2.2.0",
89
- "vite": "^6.1.1",
89
+ "vite": "^6.2.1",
90
90
  "vitest-environment-nuxt": "^1.0.1",
91
91
  "vue": "^3.5.13"
92
92
  },
93
93
  "devDependencies": {
94
94
  "@cucumber/cucumber": "11.2.0",
95
95
  "@jest/globals": "29.7.0",
96
- "@nuxt/devtools-kit": "2.1.0",
96
+ "@nuxt/devtools-kit": "2.2.1",
97
97
  "@nuxt/eslint-config": "1.1.0",
98
- "@playwright/test": "1.50.1",
98
+ "@playwright/test": "1.51.0",
99
99
  "@testing-library/vue": "8.1.0",
100
100
  "@types/estree": "1.0.6",
101
101
  "@types/jsdom": "21.1.7",
102
- "@types/node": "22.13.4",
102
+ "@types/node": "22.13.10",
103
103
  "@types/semver": "7.5.8",
104
104
  "@vue/test-utils": "2.4.6",
105
- "changelogen": "0.5.7",
105
+ "changelogen": "0.6.1",
106
106
  "compatx": "0.1.8",
107
- "eslint": "9.20.1",
107
+ "eslint": "9.22.0",
108
108
  "installed-check": "9.3.0",
109
- "knip": "5.44.4",
110
- "nitropack": "2.10.4",
111
- "nuxt": "3.15.4",
112
- "pkg-pr-new": "0.0.39",
113
- "playwright-core": "1.50.1",
114
- "rollup": "4.34.8",
109
+ "knip": "5.45.0",
110
+ "nitropack": "2.11.5",
111
+ "nuxt": "3.16.0",
112
+ "pkg-pr-new": "0.0.40",
113
+ "playwright-core": "1.51.0",
114
+ "rollup": "4.35.0",
115
115
  "semver": "7.7.1",
116
- "typescript": "5.7.3",
116
+ "typescript": "5.8.2",
117
117
  "unbuild": "latest",
118
118
  "unimport": "4.1.2",
119
- "vitest": "3.0.6",
119
+ "vitest": "3.0.8",
120
120
  "vue-router": "4.5.0",
121
- "vue-tsc": "2.2.2"
121
+ "vue-tsc": "2.2.8"
122
122
  },
123
123
  "peerDependencies": {
124
124
  "@cucumber/cucumber": "^10.3.1 || ^11.0.0",
@@ -166,17 +166,22 @@
166
166
  "resolutions": {
167
167
  "@cucumber/cucumber": "11.2.0",
168
168
  "@nuxt/devtools": "1.0.8",
169
- "@nuxt/kit": "^3.15.4",
170
- "@nuxt/schema": "^3.15.4",
169
+ "@nuxt/kit": "^3.16.0",
170
+ "@nuxt/schema": "^3.16.0",
171
171
  "@nuxt/test-utils": "workspace:*",
172
- "rollup": "4.34.8",
173
- "vite": "^6.1.1",
174
- "vite-node": "3.0.6",
175
- "vitest": "3.0.6",
172
+ "rollup": "4.35.0",
173
+ "vite": "^6.2.1",
174
+ "vite-node": "3.0.8",
175
+ "vitest": "3.0.8",
176
176
  "vue": "^3.5.13"
177
177
  },
178
178
  "engines": {
179
179
  "node": "^18.20.5 || ^20.9.0 || ^22.0.0 || >=23.0.0"
180
180
  },
181
- "packageManager": "pnpm@10.4.1"
181
+ "packageManager": "pnpm@10.6.1",
182
+ "pnpm": {
183
+ "onlyBuiltDependencies": [
184
+ "better-sqlite3"
185
+ ]
186
+ }
182
187
  }