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

Make library work with render #25

Open
blainekasten opened this issue May 19, 2016 · 5 comments
Open

Make library work with render #25

blainekasten opened this issue May 19, 2016 · 5 comments

Comments

@blainekasten
Copy link
Collaborator

Currently we are doing nothing with rendered components. chai-enzyme is supporting them nicely. We should find a way to support rendered components.

@blainekasten
Copy link
Collaborator Author

Does anybody actually use the render method with enzyme? I'm never use it and wonder if it's really necassary to support..

@pascalduez
Copy link
Contributor

pascalduez commented Sep 29, 2016

Hi,

actually I do use render for presentational components. There's often cases I want to test child elements and render is a bit easier. Otherwise you need the sub components imported to be able to assert against them.

const Svg = () => <svg />
const Foo = () => <div><Svg /></div>

With render:

expect(wrapper.find('svg').toBePresent().

With shallow:

import Svg from '...';

expect(wrapper.find(Svg).toBePresent().

Recently switched to Jest, so we might actually do more snapshots, but still.

@blainekasten
Copy link
Collaborator Author

That's good to know. Thanks for reporting. I think we'all be in an easier place to support this after #39 is done.

@luizbon
Copy link

luizbon commented Jan 12, 2017

@pascalduez you can use find by name with shallow without a problem.
What you need to do is search for your component name and not your HTML output.

so your With shallow code will be:

expect(wrapper.find('Svg')).toBePresent();

@pascalduez
Copy link
Contributor

@luizbon Thanks for the feedback, I'll give it another try.

Still, there are (few) cases where I'd like to test against "real" DOM elements, but well.

@blainekasten blainekasten added this to To do in v7 Mar 16, 2018
@blainekasten blainekasten moved this from To do to If I have time in v7 Sep 20, 2018
@blainekasten blainekasten removed this from If I have time in v7 Oct 8, 2018
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