Skip to content

Commit 6cf97bf

Browse files
committed
test: skip testing spa-preloader in dev
1 parent 9a9fcda commit 6cf97bf

File tree

2 files changed

+41
-52
lines changed

2 files changed

+41
-52
lines changed

test/spa-loader/spa-preloader-outside-disabled.test.ts

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
import { fileURLToPath } from 'node:url'
22
import { describe, expect, it } from 'vitest'
33
import { isWindows } from 'std-env'
4-
import { $fetch, createPage, fetch, setup, url } from '@nuxt/test-utils/e2e'
5-
import { expectWithPolling } from '../utils'
4+
import { $fetch, createPage, setup, url } from '@nuxt/test-utils/e2e'
65

76
const isWebpack =
87
process.env.TEST_BUILDER === 'webpack' ||
98
process.env.TEST_BUILDER === 'rspack'
109

1110
const isDev = process.env.TEST_ENV === 'dev'
1211

13-
await setup({
14-
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
15-
dev: isDev,
16-
server: true,
17-
browser: true,
18-
setupTimeout: (isWindows ? 360 : 120) * 1000,
19-
nuxtConfig: {
20-
builder: isWebpack ? 'webpack' : 'vite',
21-
spaLoadingTemplate: true,
22-
experimental: {
23-
spaLoadingTemplateLocation: 'within',
12+
if (!isDev) {
13+
await setup({
14+
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
15+
dev: isDev,
16+
server: true,
17+
browser: true,
18+
setupTimeout: (isWindows ? 360 : 120) * 1000,
19+
nuxtConfig: {
20+
builder: isWebpack ? 'webpack' : 'vite',
21+
spaLoadingTemplate: true,
22+
experimental: {
23+
spaLoadingTemplateLocation: 'within',
24+
},
2425
},
25-
},
26-
})
27-
28-
describe('spaLoadingTemplateLocation flag is set to `within`', () => {
29-
it.runIf(isDev)('should load dev server', async () => {
30-
await expectWithPolling(() => fetch('/').then(r => r.status === 200).catch(() => null), true)
3126
})
27+
}
28+
29+
describe.skipIf(isDev)('spaLoadingTemplateLocation flag is set to `within`', () => {
3230
it('should render loader inside appTag', async () => {
3331
const html = await $fetch<string>('/spa')
3432
expect(html).toContain(`<div id="__nuxt"><div data-testid="loader">loading...</div></div>`)
@@ -38,17 +36,14 @@ describe('spaLoadingTemplateLocation flag is set to `within`', () => {
3836
const page = await createPage()
3937
await page.goto(url('/spa'))
4038

41-
const loader = page.getByTestId('loader')
42-
const content = page.getByTestId('content')
43-
44-
await loader.waitFor({ state: 'visible' })
45-
expect(await content.isHidden()).toBeTruthy()
39+
await page.getByTestId('loader').waitFor({ state: 'visible' })
40+
expect(await page.getByTestId('content').isHidden()).toBeTruthy()
4641

4742
await page.waitForFunction(() => window.useNuxtApp?.() && window.useNuxtApp?.().isHydrating)
4843

49-
expect(await content.isHidden()).toBeTruthy()
44+
expect(await page.getByTestId('content').isHidden()).toBeTruthy()
5045

51-
await content.waitFor({ state: 'visible' })
46+
await page.getByTestId('content').waitFor({ state: 'visible' })
5247

5348
await page.close()
5449
}, 60_000)

test/spa-loader/spa-preloader-outside-enabled.test.ts

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
11
import { fileURLToPath } from 'node:url'
22
import { describe, expect, it } from 'vitest'
33
import { isWindows } from 'std-env'
4-
import { createPage, fetch, setup, url } from '@nuxt/test-utils/e2e'
4+
import { createPage, setup, url } from '@nuxt/test-utils/e2e'
55
import type { Page } from 'playwright-core'
6-
import { expectWithPolling } from '../utils'
76

87
const isWebpack = process.env.TEST_BUILDER === 'webpack' || process.env.TEST_BUILDER === 'rspack'
98
const isDev = process.env.TEST_ENV === 'dev'
109

11-
await setup({
12-
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
13-
dev: isDev,
14-
server: true,
15-
browser: true,
16-
setupTimeout: (isWindows ? 360 : 120) * 1000,
17-
nuxtConfig: {
18-
builder: isWebpack ? 'webpack' : 'vite',
19-
spaLoadingTemplate: true,
20-
experimental: {
21-
spaLoadingTemplateLocation: 'body',
10+
if (!isDev) {
11+
await setup({
12+
rootDir: fileURLToPath(new URL('../fixtures/spa-loader', import.meta.url)),
13+
server: true,
14+
browser: true,
15+
setupTimeout: (isWindows ? 360 : 120) * 1000,
16+
nuxtConfig: {
17+
builder: isWebpack ? 'webpack' : 'vite',
18+
spaLoadingTemplate: true,
19+
experimental: {
20+
spaLoadingTemplateLocation: 'body',
21+
},
2222
},
23-
},
24-
})
25-
26-
describe('spaLoadingTemplateLocation flag is set to `body`', () => {
27-
it.runIf(isDev)('should load dev server', async () => {
28-
await expectWithPolling(() => fetch('/').then(r => r.status === 200).catch(() => null), true)
2923
})
24+
}
25+
26+
describe.skipIf(isDev)('spaLoadingTemplateLocation flag is set to `body`', () => {
3027
it('should render spa-loader', async () => {
3128
const page = await createPage()
3229
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
3330

34-
const loader = page.getByTestId('loader')
35-
const content = page.getByTestId('content')
36-
37-
await loader.waitFor({ state: 'visible' })
38-
expect(await content.isHidden()).toBeTruthy()
31+
await page.getByTestId('loader').waitFor({ state: 'visible' })
32+
expect(await page.getByTestId('content').isHidden()).toBeTruthy()
3933

40-
await content.waitFor({ state: 'visible' })
41-
expect(await loader.isHidden()).toBeTruthy()
34+
await page.getByTestId('content').waitFor({ state: 'visible' })
35+
expect(await page.getByTestId('loader').isHidden()).toBeTruthy()
4236

4337
await page.close()
4438
}, 60_000)

0 commit comments

Comments
 (0)