mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
These tests won't ever be run in a deployed environment, so this removes `skipDeployment` so it's easier to grok which tests are intentionally disabled because they don't work when deployed.
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
describe('ssg-single-pass', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it('should only render the page once during build', async () => {
|
|
expect(next.cliOutput).toIncludeRepeated('home page rendered', 1)
|
|
})
|
|
|
|
it('should only render the page once during an ISR revalidation', async () => {
|
|
let logOccurrences = next.cliOutput.split('home page rendered').length - 1
|
|
expect(logOccurrences).toBe(1)
|
|
logOccurrences = 0
|
|
const browser = await next.browser('/')
|
|
const initialRandomNumber = await browser
|
|
.elementById('random-number')
|
|
.text()
|
|
expect(initialRandomNumber).toMatch(/\d+/)
|
|
// grab the index of the last log message so we can start
|
|
// parsing future logs from there
|
|
const outputIndex = next.cliOutput.length
|
|
|
|
// trigger a revalidation
|
|
const response = await (await next.fetch('/revalidate')).json()
|
|
expect(response.success).toBe(true)
|
|
|
|
await retry(async () => {
|
|
// Retry until the data has been revalidated
|
|
browser.refresh()
|
|
|
|
const newRandomNumber = await browser.elementById('random-number').text()
|
|
expect(newRandomNumber).toMatch(/\d+/)
|
|
expect(newRandomNumber).not.toBe(initialRandomNumber)
|
|
|
|
expect(next.cliOutput.slice(outputIndex)).toIncludeRepeated(
|
|
'home page rendered',
|
|
1
|
|
)
|
|
})
|
|
})
|
|
})
|