Skip to content

Commit

Permalink
Try to improve testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda committed Feb 15, 2017
1 parent bea21d5 commit 9370d6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions client/on-demand-entries-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
22 changes: 8 additions & 14 deletions test/integration/ondemand/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
stopApp,
waitFor
} from 'next-test-utils'
import webdriver from 'next-webdriver'

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

it('should compile pages with client side <Link />', 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
}
})
})

0 comments on commit 9370d6b

Please sign in to comment.