Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Use new Redbox matchers in pages/ service-side-dev-errors #76779

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 219 additions & 15 deletions test/integration/server-side-dev-errors/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import fs from 'fs/promises'
import { join } from 'path'
import webdriver from 'next-webdriver'
import {
assertHasRedbox,
killApp,
findPort,
launchApp,
retry,
getRedboxSource,
assertNoRedbox,
} from 'next-test-utils'
import stripAnsi from 'strip-ansi'
Expand Down Expand Up @@ -87,9 +85,38 @@ describe('server-side dev errors', () => {
'\n> 6 | missingVar;return {'
)

await assertHasRedbox(browser)
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/gsp.js (6:3) @ getStaticProps
> 6 | missingVar;return {
| ^",
"stack": [
"getStaticProps ../../test/integration/server-side-dev-errors/pages/gsp.js (6:3)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/gsp.js (6:3) @ getStaticProps
> 6 | missingVar;return {
| ^",
"stack": [
"getStaticProps pages/gsp.js (6:3)",
],
}
`)
}

expect(await getRedboxSource(browser)).toContain('missingVar')
await fs.writeFile(gspPage, content, { flush: true })
await assertNoRedbox(browser)
} finally {
Expand Down Expand Up @@ -137,9 +164,38 @@ describe('server-side dev errors', () => {
'\n> 6 | missingVar;return {'
)

await assertHasRedbox(browser)
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/gssp.js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps ../../test/integration/server-side-dev-errors/pages/gssp.js (6:3)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/gssp.js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps pages/gssp.js (6:3)",
],
}
`)
}

expect(await getRedboxSource(browser)).toContain('missingVar')
await fs.writeFile(gsspPage, content)
await assertNoRedbox(browser)
} finally {
Expand Down Expand Up @@ -187,11 +243,39 @@ describe('server-side dev errors', () => {
'\n> 6 | missingVar;return {'
)

await assertHasRedbox(browser)
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/blog/[slug].js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps ../../test/integration/server-side-dev-errors/pages/blog/[slug].js (6:3)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/blog/[slug].js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps pages/blog/[slug].js (6:3)",
],
}
`)
}

expect(await getRedboxSource(browser)).toContain('missingVar')
await fs.writeFile(dynamicGsspPage, content)
await assertHasRedbox(browser)
} finally {
await fs.writeFile(dynamicGsspPage, content)
}
Expand Down Expand Up @@ -237,11 +321,71 @@ describe('server-side dev errors', () => {
"\n> 2 | missingVar;res.status(200).json({ hello: 'world' })"
)

await assertHasRedbox(browser)
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler pages/api/hello.js (2:3)",
],
}
`)
}

expect(await getRedboxSource(browser)).toContain('missingVar')
await fs.writeFile(apiPage, content)
await assertHasRedbox(browser)

if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler pages/api/hello.js (2:3)",
],
}
`)
}
} finally {
await fs.writeFile(apiPage, content)
}
Expand Down Expand Up @@ -289,11 +433,71 @@ describe('server-side dev errors', () => {
'\n> 2 | missingVar;res.status(200).json({ slug: req.query.slug })'
)

await assertHasRedbox(browser)
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler pages/api/blog/[slug].js (2:3)",
],
}
`)
}

expect(await getRedboxSource(browser)).toContain('missingVar')
await fs.writeFile(dynamicApiPage, content)
await assertHasRedbox(browser)

if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3)",
],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler pages/api/blog/[slug].js (2:3)",
],
}
`)
}
} finally {
await fs.writeFile(dynamicApiPage, content)
}
Expand Down
Loading