Unverified Commit 58d328a0 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Use new Redbox matchers in pages/ ReactRefreshLogBox (#76391)

parent 0b49048a
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox default boundaries 1`] = `
"FunctionDefault.js (1:51) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^"
`;
exports[`ReactRefreshLogBox default conversion to class component (1) 1`] = `
"Child.js (4:11) @ ClickCount.render
2 | export default class ClickCount extends Component {
3 | render() {
> 4 | throw new Error()
| ^
5 | }
6 | }"
`;
exports[`ReactRefreshLogBox default css syntax errors 1`] = `
"./index.module.css (1:1)
Syntax error: Selector "button" is not pure (pure selectors must contain at least one local class or id)
> 1 | button {}
| ^"
`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 1`] = `"Error: end https://nextjs.org"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 2`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 3`] = `"Error: https://nextjs.org start"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 4`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 5`] = `"Error: middle https://nextjs.org end"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 6`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 8`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 10`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default module init error not shown 1`] = `
"index.js (3:7) @ eval
1 | // top offset for snapshot
2 | import * as React from 'react';
> 3 | throw new Error('no')
| ^
4 | class ClassDefault extends React.Component {
5 | render() {
6 | return <h1>Default Export</h1>;"
`;
exports[`ReactRefreshLogBox default should strip whitespace correctly with newline 1`] = `
"index.js (8:27) @ onClick
6 |
7 | <a onClick={() => {
> 8 | throw new Error('idk')
| ^
9 | }}>
10 | click me
11 | </a>"
`;
exports[`ReactRefreshLogBox turbo boundaries 1`] = `
"FunctionDefault.js (1:51) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^"
`;
exports[`ReactRefreshLogBox turbo conversion to class component (1) 1`] = `
"Child.js (4:11) @ ClickCount.render
2 | export default class ClickCount extends Component {
3 | render() {
> 4 | throw new Error()
| ^
5 | }
6 | }"
`;
exports[`ReactRefreshLogBox turbo css syntax errors 1`] = `
"./index.module.css
Parsing css source code failed
Selector is not pure (pure selectors must contain at least one local class or id), (lightningcss, Selector(button, specificity = 0x1))"
`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 1`] = `"Error: end https://nextjs.org"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 2`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 3`] = `"Error: https://nextjs.org start"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 4`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 5`] = `"Error: middle https://nextjs.org end"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 6`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 8`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 10`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo module init error not shown 1`] = `
"index.js (3:7) @ [project]/index.js [ssr] (ecmascript)
1 | // top offset for snapshot
2 | import * as React from 'react';
> 3 | throw new Error('no')
| ^
4 | class ClassDefault extends React.Component {
5 | render() {
6 | return <h1>Default Export</h1>;"
`;
exports[`ReactRefreshLogBox turbo should strip whitespace correctly with newline 1`] = `
"index.js (8:27) @ onClick
6 |
7 | <a onClick={() => {
> 8 | throw new Error('idk')
| ^
9 | }}>
10 | click me
11 | </a>"
`;
...@@ -86,7 +86,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -86,7 +86,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Text content did not match. Server: "server" Client: "client"", "description": "Text content did not match. Server: "server" Client: "client"",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -111,7 +111,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -111,7 +111,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -170,7 +170,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -170,7 +170,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <main> in <div>.", "description": "Expected server HTML to contain a matching <main> in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -193,7 +193,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -193,7 +193,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -238,7 +238,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -238,7 +238,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching text node for "second" in <div>.", "description": "Expected server HTML to contain a matching text node for "second" in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -264,7 +264,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -264,7 +264,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -301,7 +301,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -301,7 +301,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Did not expect server HTML to contain a <main> in <div>.", "description": "Did not expect server HTML to contain a <main> in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -325,7 +325,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -325,7 +325,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -360,7 +360,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -360,7 +360,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Did not expect server HTML to contain the text node "only" in <div>.", "description": "Did not expect server HTML to contain the text node "only" in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -384,7 +384,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -384,7 +384,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -431,7 +431,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -431,7 +431,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <table> in <div>.", "description": "Expected server HTML to contain a matching <table> in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -455,7 +455,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -455,7 +455,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -496,7 +496,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -496,7 +496,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <table> in <div>.", "description": "Expected server HTML to contain a matching <table> in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -520,7 +520,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -520,7 +520,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -568,7 +568,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -568,7 +568,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <main> in <div>.", "description": "Expected server HTML to contain a matching <main> in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -593,7 +593,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -593,7 +593,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:", "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -667,7 +667,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -667,7 +667,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <p> in <p>.", "description": "Expected server HTML to contain a matching <p> in <p>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -692,7 +692,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -692,7 +692,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
This will cause a hydration error.", This will cause a hydration error.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -739,7 +739,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -739,7 +739,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <div> in <p>.", "description": "Expected server HTML to contain a matching <div> in <p>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -764,7 +764,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -764,7 +764,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
This will cause a hydration error.", This will cause a hydration error.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -801,7 +801,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -801,7 +801,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <tr> in <div>.", "description": "Expected server HTML to contain a matching <tr> in <div>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -826,7 +826,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -826,7 +826,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
This will cause a hydration error.", This will cause a hydration error.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -869,7 +869,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -869,7 +869,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
"description": "Expected server HTML to contain a matching <p> in <span>.", "description": "Expected server HTML to contain a matching <p> in <span>.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
...@@ -898,7 +898,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -898,7 +898,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
This will cause a hydration error.", This will cause a hydration error.",
"environmentLabel": null, "environmentLabel": null,
"label": "Unhandled Runtime Error", "label": "Unhandled Runtime Error",
"source": undefined, "source": null,
"stack": [], "stack": [],
} }
`) `)
......
...@@ -106,7 +106,7 @@ describe('Dynamic IO Dev Errors', () => { ...@@ -106,7 +106,7 @@ describe('Dynamic IO Dev Errors', () => {
"description": "Error: Route "/no-accessed-data": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it. We don't have the exact line number added to error messages yet but you can see which component in the stack below. See more info: https://nextjs.org/docs/messages/next-prerender-missing-suspense", "description": "Error: Route "/no-accessed-data": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it. We don't have the exact line number added to error messages yet but you can see which component in the stack below. See more info: https://nextjs.org/docs/messages/next-prerender-missing-suspense",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Console Error", "label": "Console Error",
"source": undefined, "source": null,
"stack": [ "stack": [
"Page [Server] <anonymous> (2:1)", "Page [Server] <anonymous> (2:1)",
"main <anonymous> (2:1)", "main <anonymous> (2:1)",
......
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
openRedbox, openRedbox,
} from './next-test-utils' } from './next-test-utils'
import type { BrowserInterface } from './browsers/base' import type { BrowserInterface } from './browsers/base'
import { NextInstance } from 'e2e-utils'
declare global { declare global {
namespace jest { namespace jest {
...@@ -22,8 +23,13 @@ declare global { ...@@ -22,8 +23,13 @@ declare global {
* When a Redbox is hidden at first and requires manual display by clicking the toast, * When a Redbox is hidden at first and requires manual display by clicking the toast,
* use {@link toDisplayCollapsedRedbox} instead. * use {@link toDisplayCollapsedRedbox} instead.
* *
*
* If the project root appears in the snapshot, pass in the `NextInstance`
* as well to normalize the snapshot e.g. `await expect({ browser, next }).toDisplayRedbox()`.
*
* Unintented content in the snapshot should be reported to the Next.js DX team. * Unintented content in the snapshot should be reported to the Next.js DX team.
* <FIXME-internal-frame> in the snapshot would be unintended. * `<FIXME-internal-frame>` in the snapshot would be unintended.
* `<FIXME-project-root>` in the snapshot would be unintended.
* Any node_modules in the snapshot would be unintended. * Any node_modules in the snapshot would be unintended.
* Differences in the snapshot between Turbopack and Webpack would be unintended. * Differences in the snapshot between Turbopack and Webpack would be unintended.
* *
...@@ -36,8 +42,12 @@ declare global { ...@@ -36,8 +42,12 @@ declare global {
* When a Redbox is immediately displayed, * When a Redbox is immediately displayed,
* use {@link toDisplayRedbox} instead. * use {@link toDisplayRedbox} instead.
* *
* If the project root appears in the snapshot, pass in the `NextInstance`
* as well to normalize the snapshot e.g. `await expect({ browser, next }).toDisplayCollapsedRedbox()`.
*
* Unintented content in the snapshot should be reported to the Next.js DX team. * Unintented content in the snapshot should be reported to the Next.js DX team.
* <FIXME-internal-frame> in the snapshot would be unintended. * `<FIXME-internal-frame>` in the snapshot would be unintended.
* `<FIXME-project-root>` in the snapshot would be unintended.
* Any node_modules in the snapshot would be unintended. * Any node_modules in the snapshot would be unintended.
* Differences in the snapshot between Turbopack and Webpack would be unintended. * Differences in the snapshot between Turbopack and Webpack would be unintended.
* *
...@@ -59,7 +69,8 @@ interface RedboxSnapshot { ...@@ -59,7 +69,8 @@ interface RedboxSnapshot {
} }
async function createRedboxSnapshot( async function createRedboxSnapshot(
browser: BrowserInterface browser: BrowserInterface,
next: NextInstance | null
): Promise<RedboxSnapshot> { ): Promise<RedboxSnapshot> {
const [ const [
label, label,
...@@ -119,13 +130,25 @@ async function createRedboxSnapshot( ...@@ -119,13 +130,25 @@ async function createRedboxSnapshot(
focusedSource += '\n' + sourceFrameLine focusedSource += '\n' + sourceFrameLine
} }
} }
focusedSource = focusedSource.trim()
if (next !== null) {
focusedSource = focusedSource.replace(
next.testDir,
'<FIXME-project-root>'
)
}
} }
const snapshot: RedboxSnapshot = { const snapshot: RedboxSnapshot = {
environmentLabel, environmentLabel,
label, label,
description, description:
source: focusedSource?.trim(), description !== null && next !== null
? description.replace(next.testDir, '<FIXME-project-root>')
: description,
source: focusedSource,
stack, stack,
// TODO(newDevOverlay): Always return `count`. Normalizing currently to avoid assertion forks. // TODO(newDevOverlay): Always return `count`. Normalizing currently to avoid assertion forks.
count: label === 'Build Error' && count === -1 ? 1 : count, count: label === 'Build Error' && count === -1 ? 1 : count,
...@@ -143,9 +166,21 @@ async function createRedboxSnapshot( ...@@ -143,9 +166,21 @@ async function createRedboxSnapshot(
expect.extend({ expect.extend({
async toDisplayRedbox( async toDisplayRedbox(
this: MatcherContext, this: MatcherContext,
browser: BrowserInterface, browserOrContext:
| BrowserInterface
| { browser: BrowserInterface; next: NextInstance },
expectedRedboxSnapshot?: string expectedRedboxSnapshot?: string
) { ) {
let browser: BrowserInterface
let next: NextInstance
if ('browser' in browserOrContext && 'next' in browserOrContext) {
browser = browserOrContext.browser
next = browserOrContext.next
} else {
browser = browserOrContext
next = null
}
// Otherwise jest uses the async stack trace which makes it impossible to know the actual callsite of `toMatchSpeechInlineSnapshot`. // Otherwise jest uses the async stack trace which makes it impossible to know the actual callsite of `toMatchSpeechInlineSnapshot`.
// @ts-expect-error -- Not readonly // @ts-expect-error -- Not readonly
this.error = new Error() this.error = new Error()
...@@ -170,7 +205,7 @@ expect.extend({ ...@@ -170,7 +205,7 @@ expect.extend({
} }
} }
const redbox = await createRedboxSnapshot(browser) const redbox = await createRedboxSnapshot(browser, next)
// argument length is relevant. // argument length is relevant.
// Jest will update absent snapshots but fail if you specify a snapshot even if undefined. // Jest will update absent snapshots but fail if you specify a snapshot even if undefined.
...@@ -182,9 +217,21 @@ expect.extend({ ...@@ -182,9 +217,21 @@ expect.extend({
}, },
async toDisplayCollapsedRedbox( async toDisplayCollapsedRedbox(
this: MatcherContext, this: MatcherContext,
browser: BrowserInterface, browserOrContext:
| BrowserInterface
| { browser: BrowserInterface; next: NextInstance },
expectedRedboxSnapshot?: string expectedRedboxSnapshot?: string
) { ) {
let browser: BrowserInterface
let next: NextInstance | null
if ('browser' in browserOrContext && 'next' in browserOrContext) {
browser = browserOrContext.browser
next = browserOrContext.next
} else {
browser = browserOrContext
next = null
}
// Otherwise jest uses the async stack trace which makes it impossible to know the actual callsite of `toMatchSpeechInlineSnapshot`. // Otherwise jest uses the async stack trace which makes it impossible to know the actual callsite of `toMatchSpeechInlineSnapshot`.
// @ts-expect-error -- Not readonly // @ts-expect-error -- Not readonly
this.error = new Error() this.error = new Error()
...@@ -216,7 +263,7 @@ expect.extend({ ...@@ -216,7 +263,7 @@ expect.extend({
} }
} }
const redbox = await createRedboxSnapshot(browser) const redbox = await createRedboxSnapshot(browser, next)
// argument length is relevant. // argument length is relevant.
// Jest will update absent snapshots but fail if you specify a snapshot even if undefined. // Jest will update absent snapshots but fail if you specify a snapshot even if undefined.
......
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