profiler icon indicating copy to clipboard operation
profiler copied to clipboard

Consider that we stop using `container` in favor of `document.body` in tests

Open julienw opened this issue 4 years ago • 0 comments

In #3305 I disabled the new eslint test that checks when we use container. We do use container in tests for these cases:

  1. snapshot tests
  2. use of querySelector and friends

Advantages of using document.body:

  • this is standard DOM
  • we don't need to forward container from the render result to the test code
  • there's no difference with fragments or portals when doing queries
  • the queries getByText and friends are using document.body already.

Drawbacks of using document.body:

  • for Flow document.body can be null, so this can be painful to use ensureExists or $FlowExpectError eveywhere.
  • more nested output in snapshots

┆Issue is synchronized with this Jira Task

julienw avatar May 04 '21 13:05 julienw