Git Product home page Git Product logo

Comments (6)

iangreenleaf avatar iangreenleaf commented on June 14, 2024 1

Thanks, nice to know I'm not alone in this! Filed enzymejs/enzyme#2560 for it.

from enzyme-matchers.

ljharb avatar ljharb commented on June 14, 2024

That's expected - el DOES contain <MyElement className='foobar' />.

Try expect(el.hostNodes()).toContainMatchingElement('.foobar');.

from enzyme-matchers.

iangreenleaf avatar iangreenleaf commented on June 14, 2024

Upon further investigation, I've realized that this is an enzyme problem, not this library. I had initially misread a test that made me incorrectly think the problem was isolated to this library. Sorry for the mistaken report!

from enzyme-matchers.

ljharb avatar ljharb commented on June 14, 2024

@iangreenleaf i assume it's an enzyme usage problem, as i've indicated? if not, please file an issue on enzyme.

from enzyme-matchers.

iangreenleaf avatar iangreenleaf commented on June 14, 2024

@ljharb your hostNodes() suggestion didn't work because it doesn't seem to return the single element (it shows up as an empty set). But I was able to get a correct test by using a similar strategy of calling render() and Cheerio functions to parse the actual HTML.

I suspect I would get told the same thing by enzyme, that this is working as expected. I personally think it's pretty wild that enzyme would match a CSS selector for a class name that is not being rendered, but maybe I'm just a curmudgeon.

from enzyme-matchers.

ljharb avatar ljharb commented on June 14, 2024

No, I agree with you - the issue is likely that selectors match the components themselves as well as the things they render.

render() should generally be avoided and rarely needed, and i think mount should work for this case. If you file an issue on enzyme we can try to work out the problem.

from enzyme-matchers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.