Skip to content

Commit 80bd2d2

Browse files
committed
test: improve assertions for spa loading tests
1 parent 070bd10 commit 80bd2d2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ await setup({
2525
})
2626

2727
describe('spaLoadingTemplateLocation flag is set to `within`', () => {
28-
it('shoul be render loader inside appTag', async () => {
28+
it('should render loader inside appTag', async () => {
2929
const html = await $fetch<string>('/spa')
30-
expect(html.replace(/[\n\r]+/g, '')).toContain(
30+
expect(html).toContain(
3131
`<div id="__nuxt"><div data-testid="loader">loading...</div></div>`,
3232
)
3333
})
3434

35-
it.skipIf(isDev)('spa-loader does not appear while the app is mounting', async () => {
35+
it('spa-loader does not appear while the app is mounting', async () => {
3636
const browser = await getBrowser()
3737
const page = await browser.newPage({})
38-
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
38+
await page.goto(url('/spa'))
3939

4040
const loader = page.getByTestId('loader')
41+
42+
await page.waitForFunction(() => window.useNuxtApp?.() && window.useNuxtApp?.().isHydrating)
4143
expect(await loader.isHidden()).toBeTruthy()
4244

4345
await page.close()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('spaLoadingTemplateLocation flag is set to `body`', () => {
2424
it('should render spa-loader', async () => {
2525
const browser = await getBrowser()
2626
const page = await browser.newPage({})
27-
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
27+
await page.goto(url('/spa'))
2828
const loader = page.getByTestId('loader')
2929
expect(await loader.isVisible()).toBeTruthy()
3030

@@ -38,7 +38,7 @@ describe('spaLoadingTemplateLocation flag is set to `body`', () => {
3838
it('should render content without spa-loader', async () => {
3939
const browser = await getBrowser()
4040
const page = await browser.newPage({})
41-
await page.goto(url('/ssr'), { waitUntil: 'domcontentloaded' })
41+
await page.goto(url('/ssr'))
4242

4343
const loader = page.getByTestId('loader')
4444
expect(await loader.isHidden()).toBeTruthy()

0 commit comments

Comments
 (0)