Skip to content

Separate the app DOM from the tests DOM #1800

@kentcdodds

Description

@kentcdodds

🌈 Feature

Right now the tests run in the same JavaScript/DOM environment as the app. This can lead to unexpected and pretty confusing results which I (and other maintainers/contributors) have to explain over and over again to people reporting issues to react-testing-library.

Here's a simple example: https://codesandbox.io/s/n3j6r28z10

We have to tell people that they need to NOT render anything in their index.js file to avoid the issues which is annoying, inconvenient, and confusing.

I think it would make a lot of sense to run the tests in an iframe. And maybe provide a codesandbox option to run the tests with jsdom rather than the browser DOM (this would simulate local reality better for create-react-app based codesandboxes).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions