Skip to content

Commit

Permalink
Update fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Dec 6, 2024
1 parent 6fb87b5 commit f11c84f
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 50 deletions.
4 changes: 3 additions & 1 deletion test/development/acceptance-app/rsc-build-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ describe('Error overlay - RSC build errors', () => {
// Empty file
await session.patch('app/server-with-errors/error-file/error.js', '')

await session.assertHasRedbox()
await session.assertHasRedbox({
pageResponseCode: isTurbopack ? undefined : 500,
})
await expect(session.getRedboxSource()).resolves.toMatch(
/Add the "use client"/
)
Expand Down
12 changes: 3 additions & 9 deletions test/development/acceptance-app/rsc-runtime-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ describe('Error overlay - RSC runtime errors', () => {

const browser = await next.browser('/server')

await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: 500 })
const errorDescription = await getRedboxDescription(browser)

expect(errorDescription).toContain(
Expand Down Expand Up @@ -71,9 +69,7 @@ describe('Error overlay - RSC runtime errors', () => {
)

const browser = await next.browser('/server')
await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: 500 })

const errorDescription = await getRedboxDescription(browser)

Expand All @@ -91,9 +87,7 @@ describe('Error overlay - RSC runtime errors', () => {
`
)
const browser = await next.browser('/server')
await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: 500 })

const source = await getRedboxSource(browser)
// Can show the original source code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Undefined default export', () => {
await browser.waitForElementByCss('#__next')

await session.assertHasRedbox({
// TODO: really?
// Not actually broken. Just flaky 500 count
fixmeStackFramesHaveBrokenSourcemaps: true,
})
expect(await session.getRedboxDescription()).toInclude(
Expand Down
4 changes: 1 addition & 3 deletions test/development/app-dir/dynamic-error-trace/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ describe('app dir - dynamic error trace', () => {
it('should show the error trace', async () => {
const browser = await next.browser('/')

await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: 500 })

await expect(
browser.hasElementByCssSelector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ const isOwnerStackEnabled =
it('should catch invalid element from a rsc component', async () => {
const browser = await next.browser('/rsc')

await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: 500 })
const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser)

Expand Down Expand Up @@ -108,9 +106,7 @@ const isOwnerStackEnabled =
it('should catch invalid element from on ssr client component', async () => {
const browser = await next.browser('/ssr')

await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: 500 })

const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ describe('server-navigation-error', () => {
// FIXME: the first request to middleware error load didn't show the redbox, need one more reload
await browser.refresh()
await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
// additional navigation due to refresh but why 3 instead of 2?
pageResponseCode: [500, 500, 500],
})
expect(await getRedboxDescription(browser)).toMatch(
`Next.js navigation API is not allowed to be used in Middleware.`
Expand Down
50 changes: 38 additions & 12 deletions test/development/basic/hmr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { NextInstance } from 'e2e-utils'
import { outdent } from 'outdent'
import type { NextConfig } from 'next'

const isTurbopack = Boolean(process.env.TURBOPACK)

describe.each([
{ basePath: '', assetPrefix: '' },
{ basePath: '', assetPrefix: '/asset-prefix' },
Expand Down Expand Up @@ -507,7 +509,9 @@ describe.each([

await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div'))

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
const source = next.normalizeTestDirContent(
await getRedboxSource(browser)
)
Expand Down Expand Up @@ -610,7 +614,9 @@ describe.each([

browser = await webdriver(next.url, basePath + '/hmr/contact')

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxSource(browser)).toMatch(/Unexpected eof/)

await next.patchFile(aboutPage, aboutContent)
Expand Down Expand Up @@ -650,7 +656,9 @@ describe.each([
aboutContent.replace('export', 'aa=20;\nexport')
)

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxHeader(browser)).toMatch(/aa is not defined/)

await next.patchFile(aboutPage, aboutContent)
Expand Down Expand Up @@ -680,7 +688,9 @@ describe.each([
)
)

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxSource(browser)).toMatch(/an-expected-error/)

await next.patchFile(aboutPage, aboutContent)
Expand Down Expand Up @@ -719,7 +729,9 @@ describe.each([
)
)

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"Error: The default export is not a React Component in page: "/hmr/about5""`
)
Expand Down Expand Up @@ -761,7 +773,9 @@ describe.each([
)
)

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
// TODO: Replace this when webpack 5 is the default
expect(await getRedboxHeader(browser)).toMatch(
`Objects are not valid as a React child (found: [object RegExp]). If you meant to render a collection of children, use an array instead.`
Expand Down Expand Up @@ -805,7 +819,9 @@ describe.each([
)
)

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"Error: The default export is not a React Component in page: "/hmr/about7""`
)
Expand Down Expand Up @@ -849,7 +865,9 @@ describe.each([
)
)

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxHeader(browser)).toMatch('Failed to compile')

if (process.env.TURBOPACK) {
Expand Down Expand Up @@ -915,7 +933,9 @@ describe.each([
)
)

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxHeader(browser)).toMatch('Failed to compile')
let redboxSource = await getRedboxSource(browser)

Expand Down Expand Up @@ -983,7 +1003,9 @@ describe.each([
browser = await webdriver(next.url, basePath + '/hmr')
await browser.elementByCss('#error-in-gip-link').click()

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"Error: an-expected-error-in-gip"`
)
Expand Down Expand Up @@ -1024,7 +1046,9 @@ describe.each([
try {
browser = await webdriver(next.url, basePath + '/hmr/error-in-gip')

await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"Error: an-expected-error-in-gip"`
)
Expand Down Expand Up @@ -1168,7 +1192,9 @@ describe.each([
pageName,
`import hello from 'non-existent'\n` + originalContent
)
await assertHasRedbox(browser, { pageResponseCode: 500 })
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? undefined : 500,
})
await waitFor(3000)
await next.patchFile(pageName, originalContent)
await check(() => next.cliOutput.substring(outputLength), /Compiled.*?/i)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/getserversideprops/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,7 @@ const runTests = (isDev = false, isDeploy = false) => {
const browser = await webdriver(next.url, '/')
await browser.elementByCss('#non-json').click()

await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: [500, 500] })
await expect(getRedboxHeader(browser)).resolves.toMatch(
/Error serializing `.time` returned from `getServerSideProps`/
)
Expand Down
23 changes: 9 additions & 14 deletions test/e2e/prerender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import webdriver from 'next-webdriver'
import stripAnsi from 'strip-ansi'

const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
const isTurbopack = Boolean(process.env.TURBOPACK)

describe('Prerender', () => {
let next: NextInstance
Expand Down Expand Up @@ -1140,15 +1141,13 @@ describe('Prerender', () => {
// we need to reload the page to trigger getStaticProps
await browser.refresh()

return retry(async () => {
await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
const errOverlayContent = await getRedboxHeader(browser)
const errorMsg = /oops from getStaticProps/
expect(next.cliOutput).toMatch(errorMsg)
expect(errOverlayContent).toMatch(errorMsg)
await assertHasRedbox(browser, {
pageResponseCode: isTurbopack ? [500, 500, 500] : [500, 500],
})
const errOverlayContent = await getRedboxHeader(browser)
const errorMsg = /oops from getStaticProps/
expect(next.cliOutput).toMatch(errorMsg)
expect(errOverlayContent).toMatch(errorMsg)
}
)
})
Expand Down Expand Up @@ -1272,10 +1271,7 @@ describe('Prerender', () => {
// /Error serializing `.time` returned from `getStaticProps`/
// )

// FIXME: disable this
await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
})
await assertHasRedbox(browser, { pageResponseCode: [500, 500, 500] })
expect(await getRedboxHeader(browser)).toMatch(
/Failed to load static props/
)
Expand All @@ -1290,9 +1286,8 @@ describe('Prerender', () => {
// /Error serializing `.time` returned from `getStaticProps`/
// )

// FIXME: disable this
await assertHasRedbox(browser, {
fixmeStackFramesHaveBrokenSourcemaps: true,
pageResponseCode: [500, 500, 500, 500],
})
expect(await getRedboxHeader(browser)).toMatch(
/Failed to load static props/
Expand Down

0 comments on commit f11c84f

Please sign in to comment.