Skip to content

Replaced instanceof RegExp #64

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

Merged
merged 3 commits into from
Sep 8, 2021
Merged

Conversation

georgehb
Copy link
Contributor

@georgehb georgehb commented Sep 8, 2021

This caused a problem in jest which runs each test in a separate execution context
Fixes #63

This caused a problem in jest which runs each test in a separate execution context
Fixes testing-library#63
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @georgehb, LGTM (though I have a slight preference for duck typing verification instead)!

can you share in what specific circumstances this is required and add a test? We've been using regexes with pptr-testing-library in jest for years without issues 🤔

AFAICT, in order for this to affect the test, the regex would need to be coming from another v8 isolate which I'm having trouble visualizing what that looks like/why one would do that :)

@georgehb
Copy link
Contributor Author

georgehb commented Sep 8, 2021

So I'm slightly confused as well as to where the error comes from. We use jest-puppeteer to set up the test environment which launches a single puppeteer instance that's used across all of the tests.

I know jest does some amount of sandboxing to keep tests from separate files isolated which is what I think is causing the problem but I don't quite understand how it does it.

I've extracted the relevant parts into this repo which demonstrates the problem.

Co-authored-by: Patrick Hulce <[email protected]>
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use jest-puppeteer to set up the test environment which launches a single puppeteer instance that's used across all of the tests.

Ah, gotcha. Yes, if you extend puppeteer in the shared context and then create the regexp in each isolated context, that would explain this 👍

don't worry about a test then, but a comment would be great

Thanks! 🎉

@patrickhulce patrickhulce merged commit 860106b into testing-library:main Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

instanceOf RegExp doesn't work in jest
2 participants