mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-21 00:35:55 +00:00
test: add some more stability in hmr tests
This commit is contained in:
parent
7cc1e71780
commit
b0d1d6ae87
@ -1,6 +1,6 @@
|
|||||||
import { promises as fsp } from 'node:fs'
|
import { promises as fsp } from 'node:fs'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { describe, expect, it } from 'vitest'
|
import { beforeAll, describe, expect, it } from 'vitest'
|
||||||
import { isWindows } from 'std-env'
|
import { isWindows } from 'std-env'
|
||||||
import { join } from 'pathe'
|
import { join } from 'pathe'
|
||||||
import { $fetch as _$fetch, fetch, setup } from '@nuxt/test-utils/e2e'
|
import { $fetch as _$fetch, fetch, setup } from '@nuxt/test-utils/e2e'
|
||||||
@ -29,7 +29,7 @@ if (process.env.TEST_ENV !== 'built' && !isWindows) {
|
|||||||
const indexVue = await fsp.readFile(join(fixturePath, 'pages/index.vue'), 'utf8')
|
const indexVue = await fsp.readFile(join(fixturePath, 'pages/index.vue'), 'utf8')
|
||||||
|
|
||||||
describe('hmr', () => {
|
describe('hmr', () => {
|
||||||
it('should load dev server', async () => {
|
beforeAll(async () => {
|
||||||
await expectWithPolling(() => $fetch<string>('/').then(r => r.includes('Home page')).catch(() => null), true)
|
await expectWithPolling(() => $fetch<string>('/').then(r => r.includes('Home page')).catch(() => null), true)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -151,6 +151,8 @@ if (process.env.TEST_ENV !== 'built' && !isWindows) {
|
|||||||
|
|
||||||
await fsp.writeFile(join(fixturePath, 'pages/routes/non-existent.vue'), `<template><div data-testid="contents">A new route!</div></template>`)
|
await fsp.writeFile(join(fixturePath, 'pages/routes/non-existent.vue'), `<template><div data-testid="contents">A new route!</div></template>`)
|
||||||
|
|
||||||
|
await expectWithPolling(() => consoleLogs.some(log => log.text.includes('hmr')), true)
|
||||||
|
|
||||||
await page.getByRole('link').click()
|
await page.getByRole('link').click()
|
||||||
await expectWithPolling(() => page.getByTestId('contents').textContent(), 'A new route!')
|
await expectWithPolling(() => page.getByTestId('contents').textContent(), 'A new route!')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user