@nuxt/test-utils-nightly 3.21.1-20251211-185233-9800099 → 3.21.1-20251211-231043-125df0a
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/module.mjs +26 -17
- package/package.json +1 -1
package/dist/module.mjs
CHANGED
|
@@ -297,26 +297,33 @@ async function setupImportMocking(nuxt) {
|
|
|
297
297
|
|
|
298
298
|
const PLUGIN_NAME = "nuxt:vitest:nuxt-root-stub";
|
|
299
299
|
const STUB_ID = "nuxt-vitest-app-entry";
|
|
300
|
-
const NuxtRootStubPlugin =
|
|
301
|
-
const
|
|
300
|
+
const NuxtRootStubPlugin = (options) => {
|
|
301
|
+
const extension = extname(options.entry);
|
|
302
|
+
const escapedExt = extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
303
|
+
const entryPath = join(dirname(options.entry), STUB_ID + extension);
|
|
304
|
+
const idFilter = new RegExp(`${STUB_ID}(?:${escapedExt})?$`);
|
|
302
305
|
return {
|
|
303
306
|
name: PLUGIN_NAME,
|
|
304
307
|
enforce: "pre",
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return importer?.endsWith("index.html") ? id : join(dirname(options.entry), STUB_ID_WITH_EXT);
|
|
309
|
-
}
|
|
308
|
+
resolveId: {
|
|
309
|
+
filter: {
|
|
310
|
+
id: idFilter
|
|
310
311
|
},
|
|
311
|
-
async
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
312
|
+
async handler(id, importer) {
|
|
313
|
+
return importer?.endsWith("index.html") ? id : entryPath;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
load: {
|
|
317
|
+
filter: {
|
|
318
|
+
id: idFilter
|
|
319
|
+
},
|
|
320
|
+
async handler() {
|
|
321
|
+
const entryContents = readFileSync(options.entry, "utf-8");
|
|
322
|
+
return entryContents.replace("#build/root-component.mjs", options.rootStubPath);
|
|
316
323
|
}
|
|
317
324
|
}
|
|
318
325
|
};
|
|
319
|
-
}
|
|
326
|
+
};
|
|
320
327
|
|
|
321
328
|
const vitePluginBlocklist = ["vite-plugin-vue-inspector", "vite-plugin-vue-inspector:post", "vite-plugin-inspect", "nuxt:type-check"];
|
|
322
329
|
const module$1 = defineNuxtModule({
|
|
@@ -334,10 +341,12 @@ const module$1 = defineNuxtModule({
|
|
|
334
341
|
}
|
|
335
342
|
const { addVitePlugin } = await loadKit(nuxt.options.rootDir);
|
|
336
343
|
const resolver = createResolver(import.meta.url);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
344
|
+
if (nuxt.options.test || nuxt.options.dev) {
|
|
345
|
+
addVitePlugin(NuxtRootStubPlugin({
|
|
346
|
+
entry: await resolvePath("#app/entry", { alias: nuxt.options.alias }),
|
|
347
|
+
rootStubPath: await resolvePath(resolver.resolve("./runtime/nuxt-root"))
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
341
350
|
if (!nuxt.options.test && !nuxt.options.dev) {
|
|
342
351
|
nuxt.options.vite.define ||= {};
|
|
343
352
|
nuxt.options.vite.define["import.meta.vitest"] = "undefined";
|