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

[test] Use new Redbox matchers in pages/ hydration-error test (#76350)

parent 6b2aec16
...@@ -3,6 +3,7 @@ import { toMatchInlineSnapshot } from 'jest-snapshot' ...@@ -3,6 +3,7 @@ import { toMatchInlineSnapshot } from 'jest-snapshot'
import { import {
assertHasRedbox, assertHasRedbox,
getRedboxCallStack, getRedboxCallStack,
getRedboxComponentStack,
getRedboxDescription, getRedboxDescription,
getRedboxEnvironmentLabel, getRedboxEnvironmentLabel,
getRedboxSource, getRedboxSource,
...@@ -51,6 +52,7 @@ interface RedboxSnapshot { ...@@ -51,6 +52,7 @@ interface RedboxSnapshot {
environmentLabel: string environmentLabel: string
label: string label: string
description: string description: string
componentStack?: string
source: string source: string
stack: string[] stack: string[]
count: number count: number
...@@ -59,15 +61,23 @@ interface RedboxSnapshot { ...@@ -59,15 +61,23 @@ interface RedboxSnapshot {
async function createRedboxSnapshot( async function createRedboxSnapshot(
browser: BrowserInterface browser: BrowserInterface
): Promise<RedboxSnapshot> { ): Promise<RedboxSnapshot> {
const [label, environmentLabel, description, source, stack, count] = const [
await Promise.all([ label,
getRedboxLabel(browser), environmentLabel,
getRedboxEnvironmentLabel(browser), description,
getRedboxDescription(browser), source,
getRedboxSource(browser), stack,
getRedboxCallStack(browser), componentStack,
getRedboxTotalErrorCount(browser), count,
]) ] = await Promise.all([
getRedboxLabel(browser),
getRedboxEnvironmentLabel(browser),
getRedboxDescription(browser),
getRedboxSource(browser),
getRedboxCallStack(browser),
getRedboxComponentStack(browser),
getRedboxTotalErrorCount(browser),
])
// We don't need to test the codeframe logic everywhere. // We don't need to test the codeframe logic everywhere.
// Here we focus on the cursor position of the top most frame // Here we focus on the cursor position of the top most frame
...@@ -111,7 +121,7 @@ async function createRedboxSnapshot( ...@@ -111,7 +121,7 @@ async function createRedboxSnapshot(
} }
} }
return { const snapshot: RedboxSnapshot = {
environmentLabel, environmentLabel,
label, label,
description, description,
...@@ -120,6 +130,14 @@ async function createRedboxSnapshot( ...@@ -120,6 +130,14 @@ async function createRedboxSnapshot(
// 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,
} }
// Hydration diffs are only relevant to some specific errors
// so we hide them from the snapshots unless they are present.
if (componentStack !== null) {
snapshot.componentStack = componentStack
}
return snapshot
} }
expect.extend({ expect.extend({
......
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