@nuxt/test-utils-nightly 3.12.2-1713365316.ceebb2e → 3.12.2-1713801120.a3daf6e

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.
@@ -147,5 +147,10 @@ type RenderOptions = RenderOptions$1 & {
147
147
  * @param options optional options to set up your component
148
148
  */
149
149
  declare function renderSuspended<T>(component: T, options?: RenderOptions): Promise<_testing_library_vue.RenderResult>;
150
+ declare global {
151
+ interface Window {
152
+ __cleanup?: Array<() => void>;
153
+ }
154
+ }
150
155
 
151
156
  export { mockComponent, mockNuxtImport, mountSuspended, registerEndpoint, renderSuspended };
@@ -147,5 +147,10 @@ type RenderOptions = RenderOptions$1 & {
147
147
  * @param options optional options to set up your component
148
148
  */
149
149
  declare function renderSuspended<T>(component: T, options?: RenderOptions): Promise<_testing_library_vue.RenderResult>;
150
+ declare global {
151
+ interface Window {
152
+ __cleanup?: Array<() => void>;
153
+ }
154
+ }
150
155
 
151
156
  export { mockComponent, mockNuxtImport, mountSuspended, registerEndpoint, renderSuspended };
@@ -1,6 +1,6 @@
1
1
  import { defineEventHandler } from 'h3';
2
2
  import { mount } from '@vue/test-utils';
3
- import { reactive, h as h$1, Suspense, nextTick, isReadonly, unref } from 'vue';
3
+ import { reactive, h as h$1, Suspense, nextTick, isReadonly, unref, effectScope } from 'vue';
4
4
  import { defu } from 'defu';
5
5
  import { defineComponent, useRouter, h } from '#imports';
6
6
  import NuxtRoot from '#build/root-component.mjs';
@@ -174,6 +174,9 @@ async function renderSuspended(component, options) {
174
174
  const { render: renderFromTestingLibrary } = await import('@testing-library/vue');
175
175
  const { vueApp } = globalThis.__unctx__.get("nuxt-app").tryUse();
176
176
  const { render, setup } = component;
177
+ for (const fn of window.__cleanup || []) {
178
+ fn();
179
+ }
177
180
  document.querySelector(`#${WRAPPER_EL_ID}`)?.remove();
178
181
  let setupContext;
179
182
  return new Promise((resolve) => {
@@ -181,11 +184,16 @@ async function renderSuspended(component, options) {
181
184
  {
182
185
  setup: (props2, ctx) => {
183
186
  setupContext = ctx;
184
- return NuxtRoot.setup(props2, {
187
+ const scope = effectScope();
188
+ window.__cleanup || (window.__cleanup = []);
189
+ window.__cleanup.push(() => {
190
+ scope.stop();
191
+ });
192
+ return scope.run(() => NuxtRoot.setup(props2, {
185
193
  ...ctx,
186
194
  expose: () => {
187
195
  }
188
- });
196
+ }));
189
197
  },
190
198
  render: (renderContext) => (
191
199
  // See discussions in https://github.com/testing-library/vue-testing-library/issues/230
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/test-utils-nightly",
3
- "version": "3.12.2-1713365316.ceebb2e",
3
+ "version": "3.12.2-1713801120.a3daf6e",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/test-utils.git"