Handle or silence "Invalid URL" errors #690
-
Hey team I'm currently writing some tests which inject some script tags (long story, it makes sense I promise) and have got some tests that use a test / fake URL in the body of the script tag, i.e.: Now, sensibly,
Is there a good way to handle this? I feel like stubbing or spying the internals of happy-dom is not the way to go about this. I'm using vitest, and regular / raw HTML (no react etc). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
My bet is that this happens because your URL is relative and happy-dom starts with location But it really depends in what you're trying to test. It doesn't seem like that HTML should be included in the test, so you can explain your goal? |
Beta Was this translation helpful? Give feedback.
-
Hi @Codex-! As @silvenon said, you will have to set the page URL if you want to use relative URL:s (e.g. In v10.0.0 of Happy DOM a fix was released that catches errors and outputs them to the console instead of letting them be thrown which caused script execution to stop. |
Beta Was this translation helpful? Give feedback.
Hi @Codex-!
As @silvenon said, you will have to set the page URL if you want to use relative URL:s (e.g.
window.location.href = 'https://localhost:3000'
);In v10.0.0 of Happy DOM a fix was released that catches errors and outputs them to the console instead of letting them be thrown which caused script execution to stop.