-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
TypeError: dompurify_1.default.sanitize is not a function #353
Comments
I have no idea :D @tdeekens any clue? |
Isn‘t this invocation wrong? createDOMPurify.sanitize(article.body)? You need to invoke the factory? |
@tdeekens Can you give an example? Dompurify works in the browser, but fails in jest. |
Yes cause I think in your test you are not invoking the createDOMPurify function. You need to const DOMPurify = createDOMPurify(window); const clean = DOMPurify.sanitize(dirty); |
As far as I'm aware, Jest doesn't have access to "window", so this would still fail? |
Ahh, found the solution here: #29 (comment) I would suggest that this ^ should probably be in the official docs/examples. Thanks @tdeekens! |
@ChristopherGillis PRs are welcome :) |
I am trying to run my tests and I am getting an error
This is the test:
And the component:
The import
import createDOMPurify from 'dompurify';
I already tried withimport DOMPurify from 'dompurify';
orimport { sanitize } from 'dompurify';
and I am still getting the same error.Versions:
"@types/dompurify": "0.0.33",
"dompurify": "^1.0.11",
"react": "^16.8.6",
So what could I be missing?
The text was updated successfully, but these errors were encountered: