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

Replace hasRedbox() #67025

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
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
Remove hasRedbox()
in favor of `assertHasRedbox` and `assertNoRedbox`.

hasRedbox() has a hardcoded timeout of 5s that is only used for the negative assertion.
Instead, we now have dedicated assertions for the positive (`assertHasRedbox`) and negative case (`assertNoRedbox`).
The negative assertion still has the hardcoded timeout.
But the positive assertion just retries until we find the Redbox.

This speeds up tests using the positive assertion.
Removing `hasRedbox` also uncovered some unused expressions e.g. `await hasRedbox(browser)`.
These expressions probably wanted to use `expect(await hasRedbox(browser)).toBe(true)`
  • Loading branch information
eps1lon committed Jun 20, 2024
commit 520cbfff0757b04fdbd908bbf0f0af10cc07f539
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
}
`
)
expect(await session.hasRedbox()).toBe(true)
await session.assertHasRedbox()
if (process.env.TURBOPACK) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/my-package/index.js:1:13
Expand Down Expand Up @@ -92,7 +92,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`
)

expect(await session.hasRedbox()).toBe(true)
await session.assertHasRedbox()

const source = await session.getRedboxSource()
if (process.env.TURBOPACK) {
Expand Down Expand Up @@ -145,7 +145,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`
)

expect(await session.hasRedbox()).toBe(true)
await session.assertHasRedbox()

const source = await session.getRedboxSource()
if (process.env.TURBOPACK) {
Expand Down Expand Up @@ -195,7 +195,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
],
])
)
expect(await session.hasRedbox()).toBe(true)
await session.assertHasRedbox()

const source = await session.getRedboxSource()
if (process.env.TURBOPACK) {
Expand Down Expand Up @@ -234,7 +234,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
}
`
)
expect(await session.hasRedbox()).toBe(false)
await session.assertNoRedbox()
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ describe.skip('ReactRefreshLogBox scss app', () => {
`
)

expect(await session.hasRedbox()).toBe(false)
await session.assertNoRedbox()

// Syntax error
await session.patch('index.module.scss', `.button { font-size: :5px; }`)
expect(await session.hasRedbox()).toBe(true)
await session.assertHasRedbox()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()

// Fix syntax error
await session.patch('index.module.scss', `.button { font-size: 5px; }`)
expect(await session.hasRedbox()).toBe(false)
await session.assertNoRedbox()

await cleanup()
})
Expand All @@ -69,7 +69,7 @@ describe.skip('ReactRefreshLogBox scss app', () => {
// Checks for selectors that can't be prefixed.
// Selector "button" is not pure (pure selectors must contain at least one local class or id)
await session.patch('index.module.scss', `button { font-size: 5px; }`)
expect(await session.hasRedbox()).toBe(true)
await session.assertHasRedbox()
const source2 = await session.getRedboxSource()
expect(source2).toMatchSnapshot()

Expand Down
Loading
Loading