mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
test: ensure dev server is loaded before running tests
This commit is contained in:
parent
aa79b3a120
commit
f66cf928e2
@ -28,6 +28,10 @@ if (process.env.TEST_ENV !== 'built' && !isWindows) {
|
||||
const indexVue = await fsp.readFile(join(fixturePath, 'pages/index.vue'), 'utf8')
|
||||
|
||||
describe('hmr', () => {
|
||||
it('should load dev server', async () => {
|
||||
await expectWithPolling(() => $fetch<string>('/').then(r => r.includes('Home page')).catch(() => null), true)
|
||||
})
|
||||
|
||||
it('should work', async () => {
|
||||
const { page, pageErrors, consoleLogs } = await renderPage('/')
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isWindows } from 'std-env'
|
||||
import { $fetch, createPage, setup, url } from '@nuxt/test-utils/e2e'
|
||||
import { $fetch, createPage, fetch, setup, url } from '@nuxt/test-utils/e2e'
|
||||
import { expectWithPolling } from '../utils'
|
||||
|
||||
const isWebpack =
|
||||
process.env.TEST_BUILDER === 'webpack' ||
|
||||
@ -25,6 +26,9 @@ await setup({
|
||||
})
|
||||
|
||||
describe('spaLoadingTemplateLocation flag is set to `within`', () => {
|
||||
it.runIf(isDev)('should load dev server', async () => {
|
||||
await expectWithPolling(() => fetch('/').then(r => r.status === 200).catch(() => null), true)
|
||||
})
|
||||
it('should render loader inside appTag', async () => {
|
||||
const html = await $fetch<string>('/spa')
|
||||
expect(html).toContain(`<div id="__nuxt"><div data-testid="loader">loading...</div></div>`)
|
||||
|
@ -1,14 +1,16 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isWindows } from 'std-env'
|
||||
import { createPage, setup, url } from '@nuxt/test-utils/e2e'
|
||||
import { createPage, fetch, setup, url } from '@nuxt/test-utils/e2e'
|
||||
import type { Page } from 'playwright-core'
|
||||
import { expectWithPolling } from '../utils'
|
||||
|
||||
const isWebpack = process.env.TEST_BUILDER === 'webpack' || process.env.TEST_BUILDER === 'rspack'
|
||||
const isDev = process.env.TEST_ENV === 'dev'
|
||||
|
||||
await setup({
|
||||
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
|
||||
dev: process.env.TEST_ENV === 'dev',
|
||||
dev: isDev,
|
||||
server: true,
|
||||
browser: true,
|
||||
setupTimeout: (isWindows ? 360 : 120) * 1000,
|
||||
@ -22,6 +24,9 @@ await setup({
|
||||
})
|
||||
|
||||
describe('spaLoadingTemplateLocation flag is set to `body`', () => {
|
||||
it.runIf(isDev)('should load dev server', async () => {
|
||||
await expectWithPolling(() => fetch('/').then(r => r.status === 200).catch(() => null), true)
|
||||
})
|
||||
it('should render spa-loader', async () => {
|
||||
const page = await createPage()
|
||||
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
|
||||
|
Loading…
Reference in New Issue
Block a user