File size: 3,076 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
import { nextTestSetup } from 'e2e-utils'
import {
getRedboxDescription,
openRedbox,
assertNoRedbox,
retry,
} from 'next-test-utils'
describe('Cache Components Dev Errors', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should not show a red box error on the SSR render', async () => {
const browser = await next.browser('/cached')
await assertNoRedbox(browser)
let latestValue = await browser.elementByCss('#value').text()
await browser.refresh()
await assertNoRedbox(browser)
let priorValue = latestValue
latestValue = await browser.elementByCss('#value').text()
expect(latestValue).toBe(priorValue)
await browser.elementByCss('#refresh').click()
await retry(async () => {
await assertNoRedbox(browser)
let priorValue = latestValue
latestValue = await browser.elementByCss('#value').text()
expect(latestValue).not.toBe(priorValue)
})
await browser.elementByCss('#refresh').click()
await retry(async () => {
await assertNoRedbox(browser)
let priorValue = latestValue
latestValue = await browser.elementByCss('#value').text()
expect(latestValue).not.toBe(priorValue)
})
// TODO CI is too flakey to run tests like this b/c timing cannot be controlled.
// we need to land this so we're deactivating these assertions for now.
// you should be able to reproduce the assertions below when testing locally
// await browser.elementByCss('#reload').click()
// await retry(async () => {
// await assertNoRedbox(browser)
// let priorValue = latestValue
// latestValue = await browser.elementByCss('#value').text()
// expect(latestValue).toBe(priorValue)
// })
// await browser.elementByCss('#reload').click()
// await retry(async () => {
// await assertNoRedbox(browser)
// let priorValue = latestValue
// latestValue = await browser.elementByCss('#value').text()
// expect(latestValue).toBe(priorValue)
// })
// await browser.elementByCss('#refresh').click()
// await retry(async () => {
// await assertNoRedbox(browser)
// let priorValue = latestValue
// latestValue = await browser.elementByCss('#value').text()
// expect(latestValue).not.toBe(priorValue)
// })g
})
it('should show a red box error on the SSR render when data is uncached', async () => {
let desc
const browser = await next.browser('/uncached')
await openRedbox(browser)
desc = await getRedboxDescription(browser)
expect(desc).toContain(
'Route "/uncached": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it'
)
await browser.refresh()
await openRedbox(browser)
desc = await getRedboxDescription(browser)
expect(desc).toContain(
'Route "/uncached": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it'
)
})
})
|