Skip to content

Add a "missing suspense boundary" warning/error #1046

@joshribakoff-sm

Description

@joshribakoff-sm
function Suspender() {
  throw new Promise(() => null);
  return null;
}

render(<Suspender />)
screen.debug()

This logs:

  console.log
    <body>
      <div />
    </body>
    

It's missing the error:

A React component suspended while rendering, but no fallback UI was specified

In a "real" (non test) environment, you get this warning. Ideally test semantics match the real semantics.

Activity

eps1lon

eps1lon commented on Apr 12, 2022

@eps1lon
Member

This behavior changed in React 18. There is no longer a warning when there's no Suspense boundary: https://codesandbox.io/s/missing-suspense-is-fine-ir1jl4

I'll double-check if that's intended by React and just forgotten in the changelog. But it's nothing we can do on our side.

eps1lon

eps1lon commented on Apr 12, 2022

@eps1lon
Member

Intentionally changed in facebook/react#23267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @eps1lon@joshribakoff-sm

        Issue actions

          Add a "missing suspense boundary" warning/error · Issue #1046 · testing-library/react-testing-library