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
f877823a43
commit
46e2900a26
@ -29,6 +29,10 @@ 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 () => {
|
||||||
|
await expectWithPolling(() => $fetch<string>('/').then(r => r.includes('Home page')).catch(() => null), true)
|
||||||
|
})
|
||||||
|
|
||||||
it('should work', async () => {
|
it('should work', async () => {
|
||||||
const { page, pageErrors, consoleLogs } = await renderPage('/')
|
const { page, pageErrors, consoleLogs } = await renderPage('/')
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { isWindows } from 'std-env'
|
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 =
|
const isWebpack =
|
||||||
process.env.TEST_BUILDER === 'webpack' ||
|
process.env.TEST_BUILDER === 'webpack' ||
|
||||||
@ -25,6 +26,9 @@ await setup({
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('spaLoadingTemplateLocation flag is set to `within`', () => {
|
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 () => {
|
it('should render loader inside appTag', async () => {
|
||||||
const html = await $fetch<string>('/spa')
|
const html = await $fetch<string>('/spa')
|
||||||
expect(html).toContain(`<div id="__nuxt"><div data-testid="loader">loading...</div></div>`)
|
expect(html).toContain(`<div id="__nuxt"><div data-testid="loader">loading...</div></div>`)
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { isWindows } from 'std-env'
|
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 type { Page } from 'playwright-core'
|
||||||
|
import { expectWithPolling } from '../utils'
|
||||||
|
|
||||||
const isWebpack = process.env.TEST_BUILDER === 'webpack' || process.env.TEST_BUILDER === 'rspack'
|
const isWebpack = process.env.TEST_BUILDER === 'webpack' || process.env.TEST_BUILDER === 'rspack'
|
||||||
|
const isDev = process.env.TEST_ENV === 'dev'
|
||||||
|
|
||||||
await setup({
|
await setup({
|
||||||
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
|
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
|
||||||
dev: process.env.TEST_ENV === 'dev',
|
dev: isDev,
|
||||||
server: true,
|
server: true,
|
||||||
browser: true,
|
browser: true,
|
||||||
setupTimeout: (isWindows ? 360 : 120) * 1000,
|
setupTimeout: (isWindows ? 360 : 120) * 1000,
|
||||||
@ -22,6 +24,9 @@ await setup({
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('spaLoadingTemplateLocation flag is set to `body`', () => {
|
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 () => {
|
it('should render spa-loader', async () => {
|
||||||
const page = await createPage()
|
const page = await createPage()
|
||||||
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
|
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
|
||||||
|
Loading…
Reference in New Issue
Block a user