Skip to content

Commit

Permalink
Update some flakey test cases (#43247)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Nov 22, 2022
1 parent a2df178 commit 20e9148
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
6 changes: 4 additions & 2 deletions test/e2e/basepath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,10 @@ describe('basePath', () => {
},
})

const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toContain('This page could not be found')
await check(
() => browser.eval('document.documentElement.innerHTML'),
/This page could not be found/
)
})

it('should 404 when manually adding basePath with router.push', async () => {
Expand Down
18 changes: 15 additions & 3 deletions test/e2e/middleware-general/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ describe('Middleware Runtime', () => {
})

it('should have correct dynamic route params on client-transition to dynamic route', async () => {
const browser = await webdriver(next.url, '/')
const browser = await webdriver(next.url, '/404')
await check(
() => browser.eval('next.router.isReady ? "yes" : "nope"'),
'yes'
)
await browser.eval('window.beforeNav = 1')
await browser.eval('window.next.router.push("/blog/first")')
await browser.waitForElementByCss('#blog')
Expand Down Expand Up @@ -357,7 +361,11 @@ describe('Middleware Runtime', () => {
})

it('should have correct route params for rewrite from config non-dynamic route', async () => {
const browser = await webdriver(next.url, '/')
const browser = await webdriver(next.url, '/404')
await check(
() => browser.eval('next.router.isReady ? "yes" : "nope"'),
'yes'
)
await browser.eval('window.beforeNav = 1')
await browser.eval('window.next.router.push("/rewrite-1")')

Expand Down Expand Up @@ -393,7 +401,11 @@ describe('Middleware Runtime', () => {
expect(res.status).toBe(200)
expect(await res.text()).toContain('Hello World')

const browser = await webdriver(next.url, `/`)
const browser = await webdriver(next.url, `/404`)
await check(
() => browser.eval('next.router.isReady ? "yes" : "nope"'),
'yes'
)
await browser.eval('window.beforeNav = 1')
await browser.eval(`next.router.push('/rewrite-1')`)
await check(async () => {
Expand Down
10 changes: 7 additions & 3 deletions test/e2e/middleware-trailing-slash/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Middleware Runtime trailing slash', () => {
})

it('should have correct dynamic route params on client-transition to dynamic route', async () => {
const browser = await webdriver(next.url, '/')
const browser = await webdriver(next.url, '/404')
await check(
() => browser.eval('next.router.isReady ? "yes" : "no"'),
'yes'
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('Middleware Runtime trailing slash', () => {
})

it('should have correct route params for rewrite from config non-dynamic route', async () => {
const browser = await webdriver(next.url, '/')
const browser = await webdriver(next.url, '/404')
await browser.eval('window.beforeNav = 1')
await browser.eval('window.next.router.push("/rewrite-1")')

Expand Down Expand Up @@ -293,7 +293,11 @@ describe('Middleware Runtime trailing slash', () => {
expect(res.status).toBe(200)
expect(await res.text()).toContain('Hello World')

const browser = await webdriver(next.url, `/`)
const browser = await webdriver(next.url, `/404`)
await check(
() => browser.eval('next.router.isReady ? "yes" : "nope"'),
'yes'
)
await browser.eval('window.beforeNav = 1')
await browser.eval(`next.router.push('/rewrite-1')`)
await check(async () => {
Expand Down

0 comments on commit 20e9148

Please sign in to comment.