Skip to content

Commit 9370d6b

Browse files
committed
Try to improve testing.
1 parent bea21d5 commit 9370d6b

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

client/on-demand-entries-client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Router.onRouteChangeComplete = function (...args) {
1010
originalOnRouteChangeComplete(...args)
1111
}
1212

13-
// Ping every 5 seconds
14-
setInterval(ping, 5000)
13+
// Ping every 3 seconds
14+
setInterval(ping, 3000)
1515

1616
function ping () {
1717
const url = `/on-demand-entries-ping?page=${Router.pathname}`

test/integration/ondemand/test/index.test.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
stopApp,
99
waitFor
1010
} from 'next-test-utils'
11-
import webdriver from 'next-webdriver'
1211

1312
const context = {}
1413
context.app = nextServer({
@@ -31,25 +30,20 @@ describe('On Demand Entries', () => {
3130
expect(pageContent.includes('Index Page')).toBeTruthy()
3231
})
3332

34-
it('should compile pages with client side <Link />', async () => {
35-
const browser = await webdriver(context.appPort, '/')
36-
await browser.elementByCss('#about-link').click()
37-
38-
// Wait for 3 secs until the pages gets compiled
39-
await waitFor(1000 * 3)
40-
const pageContent = await browser.elementByCss('p').text()
41-
33+
it('should compile pages for JSON page requests', async () => {
34+
const pageContent = await renderViaHTTP(context.appPort, '/_next/-/pages/about')
4235
expect(pageContent.includes('About Page')).toBeTruthy()
43-
await browser.close()
4436
})
4537

4638
it('should dispose inactive pages', async () => {
4739
const aboutPagePath = resolve(__dirname, '../.next/bundles/pages/about.json')
4840
expect(existsSync(aboutPagePath)).toBeTruthy()
4941

50-
// Wait for page to get disposed
51-
await waitFor(1000 * 15)
52-
53-
expect(existsSync(aboutPagePath)).toBeFalsy()
42+
// Wait maximum of jasmine.DEFAULT_TIMEOUT_INTERVAL checking
43+
// for disposing /about
44+
while (true) {
45+
await waitFor(1000 * 1)
46+
if (!existsSync(aboutPagePath)) return
47+
}
5448
})
5549
})

0 commit comments

Comments
 (0)