Skip to content

Commit

Permalink
another attempt at invalid-href
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed Jul 25, 2020
1 parent 7b30bfa commit a297bb1
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions test/integration/invalid-href/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,18 @@ jest.retryTimes(0)
const showsError = async (pathname, regex, click = false, isWarn = false) => {
const browser = await webdriver(appPort, pathname)
try {
// wait for page to be built and navigated to
await browser.waitForElementByCss('#click-me')
if (isWarn) {
await browser.eval(`(function() {
window.warnLogs = []
var origWarn = window.console.warn
window.console.warn = function() {
var warnStr = ''
for (var i = 0; i < arguments.length; i++) {
if (i > 0) warnStr += ' ';
warnStr += arguments[i]
}
window.warnLogs.push(warnStr)
origWarn.apply(undefined, arguments)
window.console.warn = (...args) => {
window.warnLogs.push(args.join(' '))
origWarn.apply(window.console, args)
}
})()`)
}
// wait for page to be built and navigated to
await waitFor(3000)
await browser.waitForElementByCss('#click-me')
if (click) {
await browser.elementByCss('#click-me').click()
await waitFor(500)
Expand All @@ -70,6 +64,11 @@ const showsError = async (pathname, regex, click = false, isWarn = false) => {
const noError = async (pathname, click = false) => {
const browser = await webdriver(appPort, '/')
try {
await check(async () => {
const appReady = await browser.eval('!!window.next.router')
console.log('app ready: ', appReady)
return appReady ? 'ready' : 'nope'
}, 'ready')
await browser.eval(`(function() {
window.caughtErrors = []
window.addEventListener('error', function (error) {
Expand All @@ -80,8 +79,6 @@ const noError = async (pathname, click = false) => {
})
window.next.router.replace('${pathname}')
})()`)
// wait for page to be built and navigated to
await waitFor(3000)
await browser.waitForElementByCss('#click-me')
if (click) {
await browser.elementByCss('#click-me').click()
Expand Down

0 comments on commit a297bb1

Please sign in to comment.