Commit 07636dfc authored by Tobias Koppers's avatar Tobias Koppers

Make scroll test case more stable

parent 2f052b16
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
nextStart, nextStart,
nextBuild, nextBuild,
check, check,
retry,
} from 'next-test-utils' } from 'next-test-utils'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
...@@ -27,11 +28,14 @@ const runTests = () => { ...@@ -27,11 +28,14 @@ const runTests = () => {
expect(scrollRestoration).toBe('manual') expect(scrollRestoration).toBe('manual')
const scrollX = Math.floor(await browser.eval(() => window.scrollX)) let scrollX, scrollY
const scrollY = Math.floor(await browser.eval(() => window.scrollY)) await retry(async () => {
scrollX = Math.floor(await browser.eval(() => window.scrollX))
expect(scrollX).not.toBe(0) expect(scrollX).not.toBe(0)
scrollY = Math.floor(await browser.eval(() => window.scrollY))
expect(scrollY).not.toBe(0) expect(scrollY).not.toBe(0)
})
await browser.eval(() => window.next.router.push('/another')) await browser.eval(() => window.next.router.push('/another'))
...@@ -48,6 +52,7 @@ const runTests = () => { ...@@ -48,6 +52,7 @@ const runTests = () => {
}, },
}) })
await retry(async () => {
const newScrollX = Math.floor(await browser.eval(() => window.scrollX)) const newScrollX = Math.floor(await browser.eval(() => window.scrollX))
const newScrollY = Math.floor(await browser.eval(() => window.scrollY)) const newScrollY = Math.floor(await browser.eval(() => window.scrollY))
...@@ -61,6 +66,7 @@ const runTests = () => { ...@@ -61,6 +66,7 @@ const runTests = () => {
expect(scrollX).toBe(newScrollX) expect(scrollX).toBe(newScrollX)
expect(scrollY).toBe(newScrollY) expect(scrollY).toBe(newScrollY)
}) })
})
} }
describe('Scroll Back Restoration Support', () => { describe('Scroll Back Restoration Support', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment