-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Testing content of dangerouslySetInnerHTML. enzyme v3 (passed in v2) #1297
Comments
I would expect dangerouslySetInnerHTML to work in v3. |
The it('renders the use href using xlink (needed for safari)', () => {
const component = shallow(<Svg use={defaultMockProps.id} />)
expect(component.html()).toContain(`xlink:href='#${defaultMockProps.id}'`)
}) I think this is fine, and an understandable rewrite (since the component essentially just writes innerHTML). |
@aweary could this be an issue with rst-selector-parser? (the |
I tried to render Maybe, it's not a bug? |
@exitudio that seems like a bug worth filing on cheerio |
I think I know why cheerio might have done this, I remember reading that In my case i've added a test to ensure I guess the question becomes, if i add an attribute To clarify |
I was going to suggest taking guidance from the DOM. I get mixed results, but i I would probably expect .prop to function as .getAttribute (while .find is similar to .querySelector), in which case it could be argued the behaviour of v2 was correct.
|
enzyme v2 is using This code works with
So the point is we should stick on |
No, but an issue should be filed on cheerio so that v1 can adjust to this behavior. |
@exitudio can you update to cheerio's latest release, and try again? |
I've confirmed that the latest cheerio release fixes it; I'll close this with a passing test case. |
Within v2, i could set the contents of a component using
dangerouslySetInnerHTML
.Enzyme could then test this contents using the
.find
method and theprop(s)
.Within v3, the content of dangerouslySetInnerHTML is not found.
Is this something that is no longer supported or a regression? (Thinking about, it i'm surprised it ever worked!)
Or, is there an example to how to test this?Thanks for your time.
Example component:
Test Passes in v2, fails in v3
edit: removed re-written test which was going off topic and moved to another issue
The text was updated successfully, but these errors were encountered: