@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.
Files changed (2) hide show
  1. package/dist/module.mjs +26 -17
  2. 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 = createUnplugin((options) => {
301
- const STUB_ID_WITH_EXT = STUB_ID + extname(options.entry);
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
- vite: {
306
- async resolveId(id, importer) {
307
- if (id.endsWith(STUB_ID) || id.endsWith(STUB_ID_WITH_EXT)) {
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 load(id) {
312
- if (id.endsWith(STUB_ID) || id.endsWith(STUB_ID_WITH_EXT)) {
313
- const entryContents = readFileSync(options.entry, "utf-8");
314
- return entryContents.replace("#build/root-component.mjs", options.rootStubPath);
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
- addVitePlugin(NuxtRootStubPlugin.vite({
338
- entry: await resolvePath("#app/entry", { alias: nuxt.options.alias }),
339
- rootStubPath: await resolvePath(resolver.resolve("./runtime/nuxt-root"))
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/test-utils-nightly",
3
- "version": "3.21.1-20251211-185233-9800099",
3
+ "version": "3.21.1-20251211-231043-125df0a",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/test-utils.git"