0

I'm writing unit tests for a component that uses [innerHTML] to display content from backend. In the browser when the component is loaded, this warning "WARNING: sanitizing HTML stripped some content, see https://g.co/ng/security#xss thrown" is displayed in the console, but there's nothing preventing the component from behaving normally.

However, when I write any unit test for the component, even just testing if the component created and is truthy, the test is marked as failing due to this warning.

I know that the solution to removing that warning from the component is to alter the component to use a Data Pipe utilizing the DomSanitizer class -- but I'd prefer to move forward with writing the unit tests without altering the actual component itself. Is there any way I can avoid this warning only manipulating the test file? Something like catching this warning and accepting it, or some other solution that could prevent this warning from failing the entire test.

Thanks!

  • Has been solved here! [Check Out](https://stackoverflow.com/questions/39681163/angular-2-sanitizing-html-stripped-some-content-with-div-id-this-is-bug-or-fe) – Sagmar Jul 14 '22 at 21:13
  • @Sagmar Appreciate the response, but I've already looked at that post. All of those comments are specific to fixing the issue within the component itself, not fixing it within a spec jasmine test file. If possible, I'd like to allow this warning in my jasmine test file and avoid altering the component – user19294155 Jul 14 '22 at 23:25

0 Answers0