MCPcopy
hub / github.com/vercel/next.js / showsError

Function showsError

test/integration/invalid-href/test/index.test.ts:27–59  ·  view source on GitHub ↗
(pathname, regex, click = false, isWarn = false)

Source from the content-addressed store, hash-verified

25jest.retryTimes(0)
26
27const showsError = async (pathname, regex, click = false, isWarn = false) => {
28 const browser = await webdriver(appPort, pathname)
29 try {
30 // wait for page to be built and navigated to
31 await browser.waitForElementByCss('#click-me')
32 if (isWarn) {
33 await browser.eval(`(function() {
34 window.warnLogs = []
35 var origWarn = window.console.warn
36 window.console.warn = (...args) => {
37 window.warnLogs.push(args.join(' '))
38 origWarn.apply(window.console, args)
39 }
40 })()`)
41 }
42 if (click) {
43 await browser.elementByCss('#click-me').click()
44 await waitFor(500)
45 }
46 if (isWarn) {
47 await check(async () => {
48 const warnLogs = await browser.eval('window.warnLogs')
49 return warnLogs.join('\n')
50 }, regex)
51 } else {
52 await waitForRedbox(browser)
53 const errorContent = await getRedboxHeader(browser)
54 expect(errorContent).toMatch(regex)
55 }
56 } finally {
57 await browser.close()
58 }
59}
60
61const noError = async (pathname, click = false) => {
62 const browser = await webdriver(appPort, '/')

Callers 1

index.test.tsFile · 0.85

Calls 12

waitForFunction · 0.90
checkFunction · 0.90
waitForRedboxFunction · 0.90
getRedboxHeaderFunction · 0.90
webdriverFunction · 0.85
waitForElementByCssMethod · 0.80
evalMethod · 0.80
clickMethod · 0.80
elementByCssMethod · 0.80
closeMethod · 0.65
expectFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected