Unverified Commit 5d53fd00 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

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

parent f5f5be6b
...@@ -4,12 +4,10 @@ import fs from 'fs/promises' ...@@ -4,12 +4,10 @@ import fs from 'fs/promises'
import { join } from 'path' import { join } from 'path'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { import {
assertHasRedbox,
killApp, killApp,
findPort, findPort,
launchApp, launchApp,
retry, retry,
getRedboxSource,
assertNoRedbox, assertNoRedbox,
} from 'next-test-utils' } from 'next-test-utils'
import stripAnsi from 'strip-ansi' import stripAnsi from 'strip-ansi'
...@@ -87,9 +85,38 @@ describe('server-side dev errors', () => { ...@@ -87,9 +85,38 @@ describe('server-side dev errors', () => {
'\n> 6 | missingVar;return {' '\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 fs.writeFile(gspPage, content, { flush: true })
await assertNoRedbox(browser) await assertNoRedbox(browser)
} finally { } finally {
...@@ -137,9 +164,38 @@ describe('server-side dev errors', () => { ...@@ -137,9 +164,38 @@ describe('server-side dev errors', () => {
'\n> 6 | missingVar;return {' '\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 fs.writeFile(gsspPage, content)
await assertNoRedbox(browser) await assertNoRedbox(browser)
} finally { } finally {
...@@ -187,11 +243,39 @@ describe('server-side dev errors', () => { ...@@ -187,11 +243,39 @@ describe('server-side dev errors', () => {
'\n> 6 | missingVar;return {' '\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 fs.writeFile(dynamicGsspPage, content)
await assertHasRedbox(browser)
} finally { } finally {
await fs.writeFile(dynamicGsspPage, content) await fs.writeFile(dynamicGsspPage, content)
} }
...@@ -237,11 +321,71 @@ describe('server-side dev errors', () => { ...@@ -237,11 +321,71 @@ describe('server-side dev errors', () => {
"\n> 2 | missingVar;res.status(200).json({ hello: 'world' })" "\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 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 { } finally {
await fs.writeFile(apiPage, content) await fs.writeFile(apiPage, content)
} }
...@@ -289,11 +433,71 @@ describe('server-side dev errors', () => { ...@@ -289,11 +433,71 @@ describe('server-side dev errors', () => {
'\n> 2 | missingVar;res.status(200).json({ slug: req.query.slug })' '\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 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 { } finally {
await fs.writeFile(dynamicApiPage, content) await fs.writeFile(dynamicApiPage, content)
} }
......
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