Skip to content
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

Spike: Evaluate options for testing library injected DOM #535

Open
blainekasten opened this issue Aug 11, 2016 · 5 comments
Open

Spike: Evaluate options for testing library injected DOM #535

blainekasten opened this issue Aug 11, 2016 · 5 comments

Comments

@blainekasten
Copy link
Contributor

Working with external, non-react, libraries is a pain in the react ecosystem; testing is no exception. We should see if there is anything we can do, to normalize the DOM that gets injected by third party libraries.

React's TestUtils do not currently support this, so it'd be a huge win if enzyme could.

Highcharts is a decent test library.

@blainekasten
Copy link
Contributor Author

ref: #527

@blainekasten blainekasten changed the title Spike: Evaluate options for testing injected DOM Spike: Evaluate options for testing library injected DOM Aug 11, 2016
@ljharb
Copy link
Member

ljharb commented Aug 11, 2016

I'm not sure I understand - you're talking about something that's not React injecting DOM into a normally React-controlled DOM element? That seems fundamentally incompatible with the way React's supposed to work.

@blainekasten
Copy link
Contributor Author

That's exactly what it is. I agree it's not in-line with React. But a lot of people are forced to use a third party library that manipulates the DOM in some sort. I'm not sure if this idea is something that's 1) possible, or 2) an idea we'd actually want to support as the code is likely hacky.

I just figured it was worth a spike as supporting it would be pretty big compared to other react testing libraries.

I think if we can't support it, or we don't want to, we should have a document on how to test those types of components, and what a tests goal should be.

@ljharb
Copy link
Member

ljharb commented Aug 11, 2016

A document would be great regardless. I suspect it's not a pattern we wish to support, but there's no harm in investigating it.

@loudwinston
Copy link

I just ran into this issue using D3, definitely a frustrating experience. I ended up getting

Even if enzyme doesn't solve this issue, It'd be very useful to include some info about this issue in the documentation for the benefit of future developers. Mentioning some workarounds might also be useful, such as calling html() on the wrapper element (which does return the whole DOM tree, including what third-party libraries manipulated) and using cheerio or similar to do assertions (this is what I ended up doing)

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

No branches or pull requests

3 participants