mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
test: improve assertions for spa loading tests
This commit is contained in:
parent
5f59f30134
commit
21b6826c1a
@ -25,19 +25,21 @@ await setup({
|
||||
})
|
||||
|
||||
describe('spaLoadingTemplateLocation flag is set to `within`', () => {
|
||||
it('shoul be render loader inside appTag', async () => {
|
||||
it('should render loader inside appTag', async () => {
|
||||
const html = await $fetch<string>('/spa')
|
||||
expect(html.replace(/[\n\r]+/g, '')).toContain(
|
||||
expect(html).toContain(
|
||||
`<div id="__nuxt"><div data-testid="loader">loading...</div></div>`,
|
||||
)
|
||||
})
|
||||
|
||||
it.skipIf(isDev)('spa-loader does not appear while the app is mounting', async () => {
|
||||
it('spa-loader does not appear while the app is mounting', async () => {
|
||||
const browser = await getBrowser()
|
||||
const page = await browser.newPage({})
|
||||
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
|
||||
await page.goto(url('/spa'))
|
||||
|
||||
const loader = page.getByTestId('loader')
|
||||
|
||||
await page.waitForFunction(() => window.useNuxtApp?.() && window.useNuxtApp?.().isHydrating)
|
||||
expect(await loader.isHidden()).toBeTruthy()
|
||||
|
||||
await page.close()
|
||||
|
@ -24,7 +24,7 @@ describe('spaLoadingTemplateLocation flag is set to `body`', () => {
|
||||
it('should render spa-loader', async () => {
|
||||
const browser = await getBrowser()
|
||||
const page = await browser.newPage({})
|
||||
await page.goto(url('/spa'), { waitUntil: 'domcontentloaded' })
|
||||
await page.goto(url('/spa'))
|
||||
const loader = page.getByTestId('loader')
|
||||
expect(await loader.isVisible()).toBeTruthy()
|
||||
|
||||
@ -38,7 +38,7 @@ describe('spaLoadingTemplateLocation flag is set to `body`', () => {
|
||||
it('should render content without spa-loader', async () => {
|
||||
const browser = await getBrowser()
|
||||
const page = await browser.newPage({})
|
||||
await page.goto(url('/ssr'), { waitUntil: 'domcontentloaded' })
|
||||
await page.goto(url('/ssr'))
|
||||
|
||||
const loader = page.getByTestId('loader')
|
||||
expect(await loader.isHidden()).toBeTruthy()
|
||||
|
Loading…
Reference in New Issue
Block a user