Skip to content

Commit

Permalink
Remove hasRedbox()
Browse files Browse the repository at this point in the history
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 19, 2024
1 parent 9ff5c44 commit ae9a5f4
Show file tree
Hide file tree
Showing 87 changed files with 610 additions and 547 deletions.
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

0 comments on commit ae9a5f4

Please sign in to comment.