mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-19 07:51:18 +00:00
test: skip testing spa-preloader in dev
This commit is contained in:
parent
9a9fcdab5b
commit
6cf97bfe5f
@ -1,8 +1,7 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isWindows } from 'std-env'
|
||||
import { $fetch, createPage, fetch, setup, url } from '@nuxt/test-utils/e2e'
|
||||
import { expectWithPolling } from '../utils'
|
||||
import { $fetch, createPage, setup, url } from '@nuxt/test-utils/e2e'
|
||||
|
||||
const isWebpack =
|
||||
process.env.TEST_BUILDER === 'webpack' ||
|
||||
@ -10,25 +9,24 @@ const isWebpack =
|
||||
|
||||
const isDev = process.env.TEST_ENV === 'dev'
|
||||
|
||||
await setup({
|
||||
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
|
||||
dev: isDev,
|
||||
server: true,
|
||||
browser: true,
|
||||
setupTimeout: (isWindows ? 360 : 120) * 1000,
|
||||
nuxtConfig: {
|
||||
builder: isWebpack ? 'webpack' : 'vite',
|
||||
spaLoadingTemplate: true,
|
||||
experimental: {
|
||||
spaLoadingTemplateLocation: 'within',
|
||||
if (!isDev) {
|
||||
await setup({
|
||||
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
|
||||
dev: isDev,
|
||||
server: true,
|
||||
browser: true,
|
||||
setupTimeout: (isWindows ? 360 : 120) * 1000,
|
||||
nuxtConfig: {
|
||||
builder: isWebpack ? 'webpack' : 'vite',
|
||||
spaLoadingTemplate: true,
|
||||
experimental: {
|
||||
spaLoadingTemplateLocation: '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)
|
||||
})
|
||||
}
|
||||
|
||||
describe.skipIf(isDev)('spaLoadingTemplateLocation flag is set to `within`', () => {
|
||||
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>`)
|
||||
@ -38,17 +36,14 @@ describe('spaLoadingTemplateLocation flag is set to `within`', () => {
|
||||
const page = await createPage()
|
||||
await page.goto(url('/spa'))
|
||||
|
||||
const loader = page.getByTestId('loader')
|
||||
const content = page.getByTestId('content')
|
||||
|
||||
await loader.waitFor({ state: 'visible' })
|
||||
expect(await content.isHidden()).toBeTruthy()
|
||||
await page.getByTestId('loader').waitFor({ state: 'visible' })
|
||||
expect(await page.getByTestId('content').isHidden()).toBeTruthy()
|
||||
|
||||
await page.waitForFunction(() => window.useNuxtApp?.() && window.useNuxtApp?.().isHydrating)
|
||||
|
||||
expect(await content.isHidden()).toBeTruthy()
|
||||
expect(await page.getByTestId('content').isHidden()).toBeTruthy()
|
||||
|
||||
await content.waitFor({ state: 'visible' })
|
||||
await page.getByTestId('content').waitFor({ state: 'visible' })
|
||||
|
||||
await page.close()
|
||||
}, 60_000)
|
||||
|
@ -1,44 +1,38 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isWindows } from 'std-env'
|
||||
import { createPage, fetch, setup, url } from '@nuxt/test-utils/e2e'
|
||||
import { createPage, 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: isDev,
|
||||
server: true,
|
||||
browser: true,
|
||||
setupTimeout: (isWindows ? 360 : 120) * 1000,
|
||||
nuxtConfig: {
|
||||
builder: isWebpack ? 'webpack' : 'vite',
|
||||
spaLoadingTemplate: true,
|
||||
experimental: {
|
||||
spaLoadingTemplateLocation: 'body',
|
||||
if (!isDev) {
|
||||
await setup({
|
||||
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
|
||||
server: true,
|
||||
browser: true,
|
||||
setupTimeout: (isWindows ? 360 : 120) * 1000,
|
||||
nuxtConfig: {
|
||||
builder: isWebpack ? 'webpack' : 'vite',
|
||||
spaLoadingTemplate: true,
|
||||
experimental: {
|
||||
spaLoadingTemplateLocation: '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)
|
||||
})
|
||||
}
|
||||
|
||||
describe.skipIf(isDev)('spaLoadingTemplateLocation flag is set to `body`', () => {
|
||||
it('should render spa-loader', async () => {
|
||||
const page = await createPage()
|
||||
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
|
||||
|
||||
const loader = page.getByTestId('loader')
|
||||
const content = page.getByTestId('content')
|
||||
await page.getByTestId('loader').waitFor({ state: 'visible' })
|
||||
expect(await page.getByTestId('content').isHidden()).toBeTruthy()
|
||||
|
||||
await loader.waitFor({ state: 'visible' })
|
||||
expect(await content.isHidden()).toBeTruthy()
|
||||
|
||||
await content.waitFor({ state: 'visible' })
|
||||
expect(await loader.isHidden()).toBeTruthy()
|
||||
await page.getByTestId('content').waitFor({ state: 'visible' })
|
||||
expect(await page.getByTestId('loader').isHidden()).toBeTruthy()
|
||||
|
||||
await page.close()
|
||||
}, 60_000)
|
||||
|
Loading…
Reference in New Issue
Block a user