enzymejs / chai-enzyme

Chai.js assertions and convenience functions for testing React Components with enzyme
MIT License
787 stars 72 forks source link

Explicitly reference className prop due to SVGAnimatedString className #209

Closed gingerchris closed 1 year ago

gingerchris commented 6 years ago

As noted on MDN, the value of el.className might not be as expected when el is an SVGElement. Instead of the expected string, it can be an instance of SVGAnimatedString.

When this is the case, tests fail with the following error:

TypeError: this.classNames(...).split is not a function

This PR instead returns the contents of the element's class attribute when the element tagName is svg

ayrton commented 6 years ago

Can you add a test case please

gingerchris commented 6 years ago

I am struggling to write a test case that fails prior to this addition, which is frustrating as this is causing tests to fail in my codebase.

This codepen example demonstrates the className returning an SVGAnimatedString but when I add an svg to the Fixture in the className test it returns the className value specified in the markup.

What's the best way to get help on this? Should I create an issue? Thanks