(pathname, regex, click = false, isWarn = false)
| 25 | jest.retryTimes(0) |
| 26 | |
| 27 | const 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 | |
| 61 | const noError = async (pathname, click = false) => { |
| 62 | const browser = await webdriver(appPort, '/') |
no test coverage detected