From 9b5bffbbb40ad0ecbc28e732b4426fc87ab6dd61 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sat, 16 Mar 2024 13:19:07 -0700 Subject: [PATCH] test: remove wait for `networkidle` --- test/basic.test.ts | 12 +++++++----- test/utils.ts | 5 ++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/basic.test.ts b/test/basic.test.ts index 81c24fb469..9805d5fed6 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -199,13 +199,14 @@ describe('pages', () => { }) it('should render correctly when loaded on a different path', async () => { - const { page, pageErrors } = await renderPage('/proxy') + const { page, pageErrors } = await renderPage() + await page.goto(url('/proxy')) + await page.waitForFunction(() => window.useNuxtApp?.() && !window.useNuxtApp?.().isHydrating) expect(await page.innerText('body')).toContain('Composable | foo: auto imported from ~/composables/foo.ts') + expect(pageErrors).toEqual([]) await page.close() - - expect(pageErrors).toEqual([]) }) it('preserves query', async () => { @@ -1309,7 +1310,8 @@ describe('deferred app suspense resolve', () => { }) it('should fully hydrate even if there is a redirection on a page with `ssr: false`', async () => { - const { page } = await renderPage('/hydration/spa-redirection/start') + const { page } = await renderPage() + await page.goto(url('/hydration/spa-redirection/start')) await page.getByText('fully hydrated and ready to go').waitFor() await page.close() }) @@ -1641,7 +1643,7 @@ describe('server components/islands', () => { // test fallback slot with v-for expect(await page.locator('.fallback-slot-content').all()).toHaveLength(2) // test islands update - expect(await page.locator('.box').innerHTML()).toContain('"number": 101,') + await page.locator('.box').getByText('"number": 101,').waitFor() const requests = [ page.waitForResponse(response => response.url().includes('/__nuxt_island/LongAsyncComponent') && response.status() === 200), page.waitForResponse(response => response.url().includes('/__nuxt_island/AsyncServerComponent') && response.status() === 200) diff --git a/test/utils.ts b/test/utils.ts index 3c1452f920..fed5e0150e 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -38,8 +38,7 @@ export async function renderPage (path = '/') { }) if (path) { - await page.goto(url(path), { waitUntil: 'networkidle' }) - await page.waitForFunction(() => window.useNuxtApp?.()) + await gotoPath(page, path) } return { @@ -70,7 +69,7 @@ export async function expectNoClientErrors (path: string) { export async function gotoPath (page: Page, path: string) { await page.goto(url(path)) - await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, path) + await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path && !window.useNuxtApp?.().isHydrating, path) } type EqualityVal = string | number | boolean | null | undefined | RegExp