Unverified Commit 8b7b6fea authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Turbopack tests: remove assertions that duplicate webpack results (#95688)

We forked test assertions in places in the early days of merging
Turbopack. Now that we more closely align, a bunch of these had the
exact same assertions. Fold them into one.
parent 4b1c74a3
...@@ -36,15 +36,9 @@ describe('ReactRefreshLogBox app', () => { ...@@ -36,15 +36,9 @@ describe('ReactRefreshLogBox app', () => {
) )
await browser.elementByCss('a').click() await browser.elementByCss('a').click()
if (isTurbopack) {
await expect(browser).toDisplayRedbox( await expect(browser).toDisplayRedbox(
`"Expected Redbox but found no visible one."` `"Expected Redbox but found no visible one."`
) )
} else {
await expect(browser).toDisplayRedbox(
`"Expected Redbox but found no visible one."`
)
}
}) })
// https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/3#issuecomment-554137807 // https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/3#issuecomment-554137807
...@@ -215,15 +209,9 @@ describe('ReactRefreshLogBox app', () => { ...@@ -215,15 +209,9 @@ describe('ReactRefreshLogBox app', () => {
`export default function FunctionDefault() { throw new Error('no'); }` `export default function FunctionDefault() { throw new Error('no'); }`
) )
if (isTurbopack) {
await expect(browser).toDisplayRedbox( await expect(browser).toDisplayRedbox(
`"Expected Redbox but found no visible one."` `"Expected Redbox but found no visible one."`
) )
} else {
await expect(browser).toDisplayRedbox(
`"Expected Redbox but found no visible one."`
)
}
}) })
// TODO: investigate why this fails when running outside of the Next.js // TODO: investigate why this fails when running outside of the Next.js
...@@ -615,8 +603,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -615,8 +603,6 @@ describe('ReactRefreshLogBox app', () => {
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
// TODO(veil): Why Owner Stack location different?
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"description": "end https://nextjs.org", "description": "end https://nextjs.org",
...@@ -633,24 +619,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -633,24 +619,6 @@ describe('ReactRefreshLogBox app', () => {
], ],
} }
`) `)
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "end https://nextjs.org",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (5:11) @ Index.useCallback[boom]
> 5 | throw new Error('end https://nextjs.org')
| ^",
"stack": [
"Index.useCallback[boom] index.js (5:11)",
"button <anonymous>",
"Index index.js (9:7)",
"Page app/page.js (4:10)",
],
}
`)
}
expect( expect(
await session.evaluate( await session.evaluate(
...@@ -694,25 +662,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -694,25 +662,6 @@ describe('ReactRefreshLogBox app', () => {
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
// TODO(veil): Why Owner Stack location different?
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"description": "https://nextjs.org start",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (5:11) @ Index.useCallback[boom]
> 5 | throw new Error('https://nextjs.org start')
| ^",
"stack": [
"Index.useCallback[boom] index.js (5:11)",
"button <anonymous>",
"Index index.js (9:7)",
"Page app/page.js (4:10)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "https://nextjs.org start", "description": "https://nextjs.org start",
...@@ -729,7 +678,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -729,7 +678,6 @@ describe('ReactRefreshLogBox app', () => {
], ],
} }
`) `)
}
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -772,8 +720,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -772,8 +720,6 @@ describe('ReactRefreshLogBox app', () => {
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
// TODO(veil): Why Owner Stack location different?
if (isTurbopack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "middle https://nextjs.org end", "description": "middle https://nextjs.org end",
...@@ -790,24 +736,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -790,24 +736,6 @@ describe('ReactRefreshLogBox app', () => {
], ],
} }
`) `)
} else {
await expect(browser).toDisplayRedbox(`
{
"description": "middle https://nextjs.org end",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (5:11) @ Index.useCallback[boom]
> 5 | throw new Error('middle https://nextjs.org end')
| ^",
"stack": [
"Index.useCallback[boom] index.js (5:11)",
"button <anonymous>",
"Index index.js (9:7)",
"Page app/page.js (4:10)",
],
}
`)
}
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -850,25 +778,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -850,25 +778,6 @@ describe('ReactRefreshLogBox app', () => {
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
// TODO(veil): Why Owner Stack location different?
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"description": "multiple https://nextjs.org links http://example.com",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (5:11) @ Index.useCallback[boom]
> 5 | throw new Error('multiple https://nextjs.org links http://example.com')
| ^",
"stack": [
"Index.useCallback[boom] index.js (5:11)",
"button <anonymous>",
"Index index.js (9:7)",
"Page app/page.js (4:10)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "multiple https://nextjs.org links http://example.com", "description": "multiple https://nextjs.org links http://example.com",
...@@ -885,7 +794,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -885,7 +794,6 @@ describe('ReactRefreshLogBox app', () => {
], ],
} }
`) `)
}
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -1152,23 +1060,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -1152,23 +1060,6 @@ describe('ReactRefreshLogBox app', () => {
) )
// Render error should "win" and show up in fullscreen // Render error should "win" and show up in fullscreen
// TODO(veil): Why Owner Stack location different?
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"description": "Component error",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (2:44) @ Index
> 2 | if (typeof window !== 'undefined') throw new Error('Component error')
| ^",
"stack": [
"Index index.js (2:44)",
"Page app/page.js (4:10)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "Component error", "description": "Component error",
...@@ -1183,7 +1074,6 @@ describe('ReactRefreshLogBox app', () => { ...@@ -1183,7 +1074,6 @@ describe('ReactRefreshLogBox app', () => {
], ],
} }
`) `)
}
}) })
test('Call stack for client error', async () => { test('Call stack for client error', async () => {
......
...@@ -339,21 +339,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -339,21 +339,7 @@ describe('ReactRefreshLogBox', () => {
] ]
`) `)
} else { } else {
if (isTurbopack) { if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "no",
"environmentLabel": null,
"label": "Runtime Error",
"source": "FunctionDefault.js (1:51) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^",
"stack": [
"FunctionDefault FunctionDefault.js (1:51)",
],
}
`)
} else if (isRspack) {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "no", "description": "no",
...@@ -636,20 +622,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -636,20 +622,6 @@ describe('ReactRefreshLogBox', () => {
], ],
} }
`) `)
} else if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"description": "",
"environmentLabel": null,
"label": "Runtime Error",
"source": "Child.js (4:11) @ ClickCount.render
> 4 | throw new Error()
| ^",
"stack": [
"ClickCount.render Child.js (4:11)",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
...@@ -1289,7 +1261,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1289,7 +1261,6 @@ describe('ReactRefreshLogBox', () => {
const { browser } = sandbox const { browser } = sandbox
if (isReact18) { if (isReact18) {
if (isTurbopack) {
// Wait for the error to reach the correct count // Wait for the error to reach the correct count
await retry(async () => { await retry(async () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(3) expect(await getRedboxTotalErrorCount(browser)).toBe(3)
...@@ -1327,45 +1298,6 @@ describe('ReactRefreshLogBox', () => { ...@@ -1327,45 +1298,6 @@ describe('ReactRefreshLogBox', () => {
}, },
] ]
`) `)
} else {
// Wait for the error to reach the correct count
await retry(async () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(3)
})
await expect(browser).toDisplayRedbox(`
[
{
"description": "Client error",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/index.js (3:11) @ Page
> 3 | throw new Error('Client error')
| ^",
"stack": [
"Page pages/index.js (3:11)",
],
},
{
"description": "Client error",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/index.js (3:11) @ Page
> 3 | throw new Error('Client error')
| ^",
"stack": [
"Page pages/index.js (3:11)",
],
},
{
"description": "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
]
`)
}
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
......
...@@ -311,20 +311,6 @@ describe('pages/ error recovery', () => { ...@@ -311,20 +311,6 @@ describe('pages/ error recovery', () => {
], ],
} }
`) `)
} else if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"description": "oops",
"environmentLabel": null,
"label": "Runtime Error",
"source": "child.js (3:9) @ Child
> 3 | throw new Error('oops')
| ^",
"stack": [
"Child child.js (3:9)",
],
}
`)
} else { } else {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
......
...@@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils' ...@@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils'
import { waitForNoRedbox } from 'next-test-utils' import { waitForNoRedbox } from 'next-test-utils'
describe('Cache Components Fallback Validation', () => { describe('Cache Components Fallback Validation', () => {
const { isTurbopack, next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
...@@ -49,7 +49,6 @@ describe('Cache Components Fallback Validation', () => { ...@@ -49,7 +49,6 @@ describe('Cache Components Fallback Validation', () => {
await browser.loadPage( await browser.loadPage(
`${next.url}/partial/prerendered/unwrapped/prerendered` `${next.url}/partial/prerendered/unwrapped/prerendered`
) )
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -64,40 +63,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -64,40 +63,8 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
> 6 | Top: {(await props.params).top}, Bottom: {(await props.params).bottom}
| ^",
"stack": [
"Page app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26)",
],
}
`)
}
await browser.loadPage(`${next.url}/partial/prerendered/unwrapped/novel`) await browser.loadPage(`${next.url}/partial/prerendered/unwrapped/novel`)
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
> 6 | Top: {(await props.params).top}, Bottom: {(await props.params).bottom}
| ^",
"stack": [
"Page app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26)",
],
}
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -112,25 +79,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -112,25 +79,8 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
}
await browser.loadPage(`${next.url}/partial/novel/unwrapped/novel`) await browser.loadPage(`${next.url}/partial/novel/unwrapped/novel`)
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/partial/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/partial/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -145,29 +95,12 @@ describe('Cache Components Fallback Validation', () => { ...@@ -145,29 +95,12 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
}
}) })
it('should warn about missing Suspense when accessing params if static params are entirely missing at build time', async () => { it('should warn about missing Suspense when accessing params if static params are entirely missing at build time', async () => {
// when the params are partially complete we don't expect to see any errors awaiting the params that are known // when the params are partially complete we don't expect to see any errors awaiting the params that are known
// but do expect errors awaiting the params that are not known if not inside a Suspense boundary. // but do expect errors awaiting the params that are not known if not inside a Suspense boundary.
const browser = await next.browser('/none/prerendered/wrapped/prerendered') const browser = await next.browser('/none/prerendered/wrapped/prerendered')
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
> 10 | await params
| ^",
"stack": [
"Layout app/none/[top]/wrapped/layout.tsx (10:3)",
],
}
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -182,10 +115,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -182,10 +115,8 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
}
await browser.loadPage(`${next.url}/none/prerendered/wrapped/novel`) await browser.loadPage(`${next.url}/none/prerendered/wrapped/novel`)
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -200,40 +131,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -200,40 +131,8 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
> 10 | await params
| ^",
"stack": [
"Layout app/none/[top]/wrapped/layout.tsx (10:3)",
],
}
`)
}
await browser.loadPage(`${next.url}/none/novel/wrapped/novel`) await browser.loadPage(`${next.url}/none/novel/wrapped/novel`)
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
> 10 | await params
| ^",
"stack": [
"Layout app/none/[top]/wrapped/layout.tsx (10:3)",
],
}
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -248,10 +147,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -248,10 +147,8 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
}
await browser.loadPage(`${next.url}/none/prerendered/unwrapped/prerendered`) await browser.loadPage(`${next.url}/none/prerendered/unwrapped/prerendered`)
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -266,40 +163,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -266,40 +163,8 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/none/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
}
await browser.loadPage(`${next.url}/none/prerendered/unwrapped/novel`) await browser.loadPage(`${next.url}/none/prerendered/unwrapped/novel`)
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/none/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -314,25 +179,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -314,25 +179,8 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
}
await browser.loadPage(`${next.url}/none/novel/unwrapped/novel`) await browser.loadPage(`${next.url}/none/novel/unwrapped/novel`)
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1400",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/none/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1400", "code": "E1400",
...@@ -347,6 +195,5 @@ describe('Cache Components Fallback Validation', () => { ...@@ -347,6 +195,5 @@ describe('Cache Components Fallback Validation', () => {
], ],
} }
`) `)
}
}) })
}) })
...@@ -39,27 +39,6 @@ describe('react-dom/server in React Server environment', () => { ...@@ -39,27 +39,6 @@ describe('react-dom/server in React Server environment', () => {
) )
await waitForNoRedbox(browser) await waitForNoRedbox(browser)
if (isTurbopack) {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{
"default": [
"renderToReadableStream",
"renderToStaticMarkup",
"renderToString",
"resume",
"version"
],
"named": [
"default",
"renderToReadableStream",
"renderToStaticMarkup",
"renderToString",
"resume",
"version"
]
}"
`)
} else {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(` expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{ "{
"default": [ "default": [
...@@ -79,26 +58,17 @@ describe('react-dom/server in React Server environment', () => { ...@@ -79,26 +58,17 @@ describe('react-dom/server in React Server environment', () => {
] ]
}" }"
`) `)
}
const redbox = { const redbox = {
description: await getRedboxDescription(browser), description: await getRedboxDescription(browser),
source: await getRedboxSource(browser), source: await getRedboxSource(browser),
} }
if (isTurbopack) {
expect(redbox).toMatchInlineSnapshot(` expect(redbox).toMatchInlineSnapshot(`
{ {
"description": null, "description": null,
"source": null, "source": null,
} }
`) `)
} else {
expect(redbox).toMatchInlineSnapshot(`
{
"description": null,
"source": null,
}
`)
}
}) })
it('explicit react-dom/server.edge usage in app code', async () => { it('explicit react-dom/server.edge usage in app code', async () => {
...@@ -156,21 +126,12 @@ describe('react-dom/server in React Server environment', () => { ...@@ -156,21 +126,12 @@ describe('react-dom/server in React Server environment', () => {
description: await getRedboxDescription(browser), description: await getRedboxDescription(browser),
source: await getRedboxSource(browser), source: await getRedboxSource(browser),
} }
if (isTurbopack) {
expect(redbox).toMatchInlineSnapshot(`
{
"description": null,
"source": null,
}
`)
} else {
expect(redbox).toMatchInlineSnapshot(` expect(redbox).toMatchInlineSnapshot(`
{ {
"description": null, "description": null,
"source": null, "source": null,
} }
`) `)
}
}) })
it('implicit react-dom/server.edge usage in app code', async () => { it('implicit react-dom/server.edge usage in app code', async () => {
...@@ -510,21 +471,12 @@ describe('react-dom/server in React Server environment', () => { ...@@ -510,21 +471,12 @@ describe('react-dom/server in React Server environment', () => {
description: await getRedboxDescription(browser), description: await getRedboxDescription(browser),
source: await getRedboxSource(browser), source: await getRedboxSource(browser),
} }
if (isTurbopack) {
expect(redbox).toMatchInlineSnapshot(`
{
"description": null,
"source": null,
}
`)
} else {
expect(redbox).toMatchInlineSnapshot(` expect(redbox).toMatchInlineSnapshot(`
{ {
"description": null, "description": null,
"source": null, "source": null,
} }
`) `)
}
}) })
it('implicit react-dom/server.edge usage in library code', async () => { it('implicit react-dom/server.edge usage in library code', async () => {
...@@ -533,29 +485,6 @@ describe('react-dom/server in React Server environment', () => { ...@@ -533,29 +485,6 @@ describe('react-dom/server in React Server environment', () => {
) )
await waitForNoRedbox(browser) await waitForNoRedbox(browser)
if (isTurbopack) {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{
"default": {
"default": [
"renderToReadableStream",
"renderToStaticMarkup",
"renderToString",
"resume",
"version"
],
"named": [
"default",
"renderToReadableStream",
"renderToStaticMarkup",
"renderToString",
"resume",
"version"
]
}
}"
`)
} else {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(` expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{ "{
"default": { "default": {
...@@ -577,26 +506,17 @@ describe('react-dom/server in React Server environment', () => { ...@@ -577,26 +506,17 @@ describe('react-dom/server in React Server environment', () => {
} }
}" }"
`) `)
}
const redbox = { const redbox = {
description: await getRedboxDescription(browser), description: await getRedboxDescription(browser),
source: await getRedboxSource(browser), source: await getRedboxSource(browser),
} }
if (isTurbopack) {
expect(redbox).toMatchInlineSnapshot(`
{
"description": null,
"source": null,
}
`)
} else {
expect(redbox).toMatchInlineSnapshot(` expect(redbox).toMatchInlineSnapshot(`
{ {
"description": null, "description": null,
"source": null, "source": null,
} }
`) `)
}
}) })
it('explicit react-dom/server.node usage in library code', async () => { it('explicit react-dom/server.node usage in library code', async () => {
......
...@@ -16,10 +16,6 @@ describe('Invalid Image Import (dev)', () => { ...@@ -16,10 +16,6 @@ describe('Invalid Image Import (dev)', () => {
const description = await getRedboxDescription(browser) const description = await getRedboxDescription(browser)
if (isTurbopack) { if (isTurbopack) {
expect(description).toContain('Processing image failed') expect(description).toContain('Processing image failed')
} else if (process.env.NEXT_RSPACK) {
expect(description).toContain(
'Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.'
)
} else { } else {
expect(description).toContain( expect(description).toContain(
'Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.' 'Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.'
...@@ -34,11 +30,6 @@ describe('Invalid Image Import (dev)', () => { ...@@ -34,11 +30,6 @@ describe('Invalid Image Import (dev)', () => {
expect(source).toContain( expect(source).toContain(
'Source code does not contain a <svg> root element' 'Source code does not contain a <svg> root element'
) )
} else if (process.env.NEXT_RSPACK) {
expect(source).toContain('./pages/index.js')
expect(source).toContain(
'Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.'
)
} else { } else {
expect(source).toContain('./pages/index.js') expect(source).toContain('./pages/index.js')
expect(source).toContain( expect(source).toContain(
......
...@@ -13,7 +13,7 @@ export function runTests(ctx: { ...@@ -13,7 +13,7 @@ export function runTests(ctx: {
isTurbopack: boolean isTurbopack: boolean
middlewareEnabled: boolean middlewareEnabled: boolean
}) { }) {
const { next, isNextDev, isTurbopack, middlewareEnabled } = ctx const { next, isNextDev, middlewareEnabled } = ctx
if (isNextStart) { if (isNextStart) {
it('should have correct cache entries on prefetch', async () => { it('should have correct cache entries on prefetch', async () => {
...@@ -1615,7 +1615,6 @@ export function runTests(ctx: { ...@@ -1615,7 +1615,6 @@ export function runTests(ctx: {
await next.readFile('.next/server/pages-manifest.json') await next.readFile('.next/server/pages-manifest.json')
) )
if (isTurbopack) {
expect(manifest).toMatchInlineSnapshot(` expect(manifest).toMatchInlineSnapshot(`
{ {
"/": "pages/index.html", "/": "pages/index.html",
...@@ -1643,35 +1642,6 @@ export function runTests(ctx: { ...@@ -1643,35 +1642,6 @@ export function runTests(ctx: {
"/p1/p2/predefined-ssg/[...rest]": "pages/p1/p2/predefined-ssg/[...rest].js", "/p1/p2/predefined-ssg/[...rest]": "pages/p1/p2/predefined-ssg/[...rest].js",
} }
`) `)
} else {
expect(manifest).toMatchInlineSnapshot(`
{
"/": "pages/index.html",
"/404": "pages/404.html",
"/[name]": "pages/[name].js",
"/[name]/[comment]": "pages/[name]/[comment].js",
"/[name]/[comment]/[...rest]": "pages/[name]/[comment]/[...rest].js",
"/[name]/comments": "pages/[name]/comments.js",
"/[name]/on-mount-redir": "pages/[name]/on-mount-redir.html",
"/_app": "pages/_app.js",
"/_document": "pages/_document.js",
"/_error": "pages/_error.js",
"/another": "pages/another.html",
"/b/[123]": "pages/b/[123].js",
"/blog/[name]/comment/[id]": "pages/blog/[name]/comment/[id].js",
"/c/[alongparamnameshouldbeallowedeventhoughweird]": "pages/c/[alongparamnameshouldbeallowedeventhoughweird].js",
"/catchall-dash/[...hello-world]": "pages/catchall-dash/[...hello-world].html",
"/d/[id]": "pages/d/[id].html",
"/dash/[hello-world]": "pages/dash/[hello-world].html",
"/index/[...slug]": "pages/index/[...slug].html",
"/on-mount/[post]": "pages/on-mount/[post].html",
"/p1/p2/all-ssg/[...rest]": "pages/p1/p2/all-ssg/[...rest].js",
"/p1/p2/all-ssr/[...rest]": "pages/p1/p2/all-ssr/[...rest].js",
"/p1/p2/nested-all-ssg/[...rest]": "pages/p1/p2/nested-all-ssg/[...rest].js",
"/p1/p2/predefined-ssg/[...rest]": "pages/p1/p2/predefined-ssg/[...rest].js",
}
`)
}
}) })
} }
} }
...@@ -11,13 +11,8 @@ describe('import-meta', () => { ...@@ -11,13 +11,8 @@ describe('import-meta', () => {
const testData = $('#test-data').text() const testData = $('#test-data').text()
const data = JSON.parse(testData) const data = JSON.parse(testData)
if (isTurbopack) {
expect(data.url).toStartWith('file:///') expect(data.url).toStartWith('file:///')
expect(data.url).toEndWith('/pages/index.tsx') expect(data.url).toEndWith('/pages/index.tsx')
} else {
expect(data.url).toStartWith('file:///')
expect(data.url).toEndWith('/pages/index.tsx')
}
}) })
it('should work in browser', async () => { it('should work in browser', async () => {
......
...@@ -115,11 +115,7 @@ describe('Static Image Component Tests', () => { ...@@ -115,11 +115,7 @@ describe('Static Image Component Tests', () => {
it('Should add a blur placeholder to statically imported jpg', async () => { it('Should add a blur placeholder to statically imported jpg', async () => {
const $ = cheerio.load(html) const $ = cheerio.load(html)
const style = $('#basic-static').attr('style') const style = $('#basic-static').attr('style')
if (isTurbopack) { if (isNextDev && !isTurbopack) {
expect(replaceDataUrl(style)).toMatchInlineSnapshot(
`"position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url("data:<REPLACED>")"`
)
} else if (isNextDev) {
// In webpack dev, `next/legacy/image` emits a dynamic blur URL via the // In webpack dev, `next/legacy/image` emits a dynamic blur URL via the
// image optimizer route instead of an inlined base64 data URL, to avoid // image optimizer route instead of an inlined base64 data URL, to avoid
// slowing down the dev server (see // slowing down the dev server (see
......
...@@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils' ...@@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils'
import { join } from 'path' import { join } from 'path'
describe('Custom Properties: Pass-Through IE11', () => { describe('Custom Properties: Pass-Through IE11', () => {
const { next, isTurbopack } = nextTestSetup({ const { next } = nextTestSetup({
files: join(__dirname, 'fixtures', 'cp-ie-11'), files: join(__dirname, 'fixtures', 'cp-ie-11'),
}) })
...@@ -17,20 +17,14 @@ describe('Custom Properties: Pass-Through IE11', () => { ...@@ -17,20 +17,14 @@ describe('Custom Properties: Pass-Through IE11', () => {
.replace(/\/\*.*?\*\//g, '') .replace(/\/\*.*?\*\//g, '')
.trim() .trim()
if (isTurbopack) { expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
expect( `":root{--color:red}h1{color:var(--color)}"`
cssContent.replace(/\/\*.*?\*\//g, '').trim() )
).toMatchInlineSnapshot(`":root{--color:red}h1{color:var(--color)}"`)
} else {
expect(
cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`":root{--color:red}h1{color:var(--color)}"`)
}
}) })
}) })
describe('Custom Properties: Pass-Through Modern', () => { describe('Custom Properties: Pass-Through Modern', () => {
const { next, isTurbopack } = nextTestSetup({ const { next } = nextTestSetup({
files: join(__dirname, 'fixtures', 'cp-modern'), files: join(__dirname, 'fixtures', 'cp-modern'),
}) })
...@@ -45,15 +39,9 @@ describe('Custom Properties: Pass-Through Modern', () => { ...@@ -45,15 +39,9 @@ describe('Custom Properties: Pass-Through Modern', () => {
.replace(/\/\*.*?\*\//g, '') .replace(/\/\*.*?\*\//g, '')
.trim() .trim()
if (isTurbopack) { expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
expect( `":root{--color:red}h1{color:var(--color)}"`
cssContent.replace(/\/\*.*?\*\//g, '').trim() )
).toMatchInlineSnapshot(`":root{--color:red}h1{color:var(--color)}"`)
} else {
expect(
cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`":root{--color:red}h1{color:var(--color)}"`)
}
}) })
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment