Skip to content

Commit 5c9c036

Browse files
committed
test: add e2e test for ignoring redirect pages
1 parent 18b652f commit 5c9c036

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

playground/nuxt.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ import { defineNuxtConfig } from 'nuxt/config'
22

33
export default defineNuxtConfig({
44
modules: ['@nuxtjs/html-validator'],
5+
routeRules: {
6+
'/redirect': {
7+
redirect: '/',
8+
},
9+
},
510
compatibilityDate: '2024-08-19',
611
})

test/module-prerender.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ await setup({
2020
hooks: {
2121
'modules:before'() {
2222
const nuxt = useNuxt()
23-
nuxt.options.nitro.prerender = { routes: ['/'] }
23+
nuxt.options.nitro.prerender = { routes: ['/', '/redirect'] }
2424
},
2525
},
2626
},
@@ -44,4 +44,17 @@ describe('Nuxt prerender', () => {
4444
),
4545
)
4646
})
47+
48+
it('ignores redirect pages', async () => {
49+
const ctx = useTestContext()
50+
const html = await fsp.readFile(
51+
resolve(ctx.nuxt!.options.nitro.output?.dir || '', 'public/redirect/index.html'),
52+
'utf-8',
53+
)
54+
55+
expect(html).toMatchInlineSnapshot(`"<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=/"></head></html>"`)
56+
expect(console.error).not.toHaveBeenCalledWith(
57+
expect.stringContaining('<html> element must have <body> as content'),
58+
)
59+
})
4760
})

0 commit comments

Comments
 (0)