diff --git a/pages/API/page-scroll-to/page-scroll-to.test.js b/pages/API/page-scroll-to/page-scroll-to.test.js index 5a3c1be8b35fa86eb0098927021eb7b788278ab7..c579d4483b9292a6376aaa2336745c9387e5a425 100644 --- a/pages/API/page-scroll-to/page-scroll-to.test.js +++ b/pages/API/page-scroll-to/page-scroll-to.test.js @@ -13,7 +13,9 @@ describe('page-scroll-to', () => { await page.waitFor(300) const scrollTop = await page.scrollTop() - expect(scrollTop).toBe(100) + + // 设备精度问题,允许上下浮动 1px + expect(scrollTop > 99 && scrollTop < 101).toBe(true) }) it('scroll-to-element', async () => { const btnScrollTo = await page.$('.btn-scrollToElement') @@ -25,4 +27,4 @@ describe('page-scroll-to', () => { const offset = await scrollToElement.offset() expect(offset.top >= 1188).toBe(true) }) -}) +}) \ No newline at end of file