MCPcopy
hub / github.com/nuxt/nuxt / renderPage

Function renderPage

test/utils.ts:11–50  ·  view source on GitHub ↗
(path = '/', opts?: { retries?: number })

Source from the content-addressed store, hash-verified

9import { isRenderingJson } from './matrix'
10
11export async function renderPage (path = '/', opts?: { retries?: number }) {
12 const ctx = useTestContext()
13 if (!ctx.options.browser) {
14 throw new Error('`renderPage` require `options.browser` to be set')
15 }
16
17 const browser = await getBrowser()
18 const page = await browser.newPage({})
19 const pageErrors: Error[] = []
20 const requests: string[] = []
21 const consoleLogs: { type: string, text: string }[] = []
22
23 page.on('console', (message) => {
24 consoleLogs.push({
25 type: message.type(),
26 text: message.text(),
27 })
28 })
29 page.on('pageerror', (err) => {
30 pageErrors.push(err)
31 })
32 page.on('request', (req) => {
33 try {
34 requests.push(req.url().replace(url('/'), '/'))
35 } catch {
36 // TODO
37 }
38 })
39
40 if (path) {
41 await gotoPath(page, path, opts?.retries)
42 }
43
44 return {
45 page,
46 pageErrors,
47 requests,
48 consoleLogs,
49 }
50}
51
52export async function expectNoClientErrors (path: string) {
53 const ctx = useTestContext()

Callers 3

basic.test.tsFile · 0.90
expectNoClientErrorsFunction · 0.85

Calls 2

gotoPathFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…