diff --git a/client/on-demand-entries-client.js b/client/on-demand-entries-client.js index 17c437e1026b0b..0ab9c0d3c15695 100644 --- a/client/on-demand-entries-client.js +++ b/client/on-demand-entries-client.js @@ -10,8 +10,8 @@ Router.onRouteChangeComplete = function (...args) { originalOnRouteChangeComplete(...args) } -// Ping every 5 seconds -setInterval(ping, 5000) +// Ping every 3 seconds +setInterval(ping, 3000) function ping () { const url = `/on-demand-entries-ping?page=${Router.pathname}` diff --git a/test/integration/ondemand/test/index.test.js b/test/integration/ondemand/test/index.test.js index 6177995ed166ea..8fc19ed9205136 100644 --- a/test/integration/ondemand/test/index.test.js +++ b/test/integration/ondemand/test/index.test.js @@ -8,7 +8,6 @@ import { stopApp, waitFor } from 'next-test-utils' -import webdriver from 'next-webdriver' const context = {} context.app = nextServer({ @@ -31,25 +30,20 @@ describe('On Demand Entries', () => { expect(pageContent.includes('Index Page')).toBeTruthy() }) - it('should compile pages with client side ', async () => { - const browser = await webdriver(context.appPort, '/') - await browser.elementByCss('#about-link').click() - - // Wait for 3 secs until the pages gets compiled - await waitFor(1000 * 3) - const pageContent = await browser.elementByCss('p').text() - + it('should compile pages for JSON page requests', async () => { + const pageContent = await renderViaHTTP(context.appPort, '/_next/-/pages/about') expect(pageContent.includes('About Page')).toBeTruthy() - await browser.close() }) it('should dispose inactive pages', async () => { const aboutPagePath = resolve(__dirname, '../.next/bundles/pages/about.json') expect(existsSync(aboutPagePath)).toBeTruthy() - // Wait for page to get disposed - await waitFor(1000 * 15) - - expect(existsSync(aboutPagePath)).toBeFalsy() + // Wait maximum of jasmine.DEFAULT_TIMEOUT_INTERVAL checking + // for disposing /about + while (true) { + await waitFor(1000 * 1) + if (!existsSync(aboutPagePath)) return + } }) })