Skip to content

Commit

Permalink
test: remove wait for networkidle
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 16, 2024
1 parent f9fe282 commit 9b5bffb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 7 additions & 5 deletions test/basic.test.ts
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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()
})
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions test/utils.ts
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Check failure on line 72 in test/utils.ts

View workflow job for this annotation

GitHub Actions / test-fixtures (windows-latest, dev, vite, async, manifest-on, 18)

test/basic.test.ts > Node.js compatibility for client-side > should work

TimeoutError: page.waitForFunction: Timeout 30000ms exceeded. ❯ gotoPath test/utils.ts:72:14 ❯ Module.renderPage test/utils.ts:41:5 ❯ test/basic.test.ts:2499:22
}

type EqualityVal = string | number | boolean | null | undefined | RegExp
Expand Down

0 comments on commit 9b5bffb

Please sign in to comment.