JSDOM error handling
See original GitHub issueIs there any way to make JSDOM forward script errors to Node.js?
I assumed the following would log undefined has no method 'toString'
but the errors are null:
jsdom.env(
'<html><script>nonExistentVariable.toString()</script></html>'
, []
, function (errors, window) {
console.log(errors)
}
)
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How can I catch errors thrown by my jsdom.jqueryify callback?
js is the stack trace of an error that occurs on the last line (line number 9). The error that occurs on line...
Read more >jsdom - npm
Script execution errors that are not handled by a window onerror event handler that returns true or calls event.preventDefault(); Not- ...
Read more >jsdom - Mediumish
Note that as of our 7.0.0 release, jsdom requires Node.js 4 or newer (why?). ... Script execution errors that are not handled by...
Read more >How to use the jsdom.VirtualConsole function in jsdom - Snyk
function mockify(html = '') { // Start of message that we want to suppress. let msg = 'Error: Not implemented: HTMLCanvasElement.prototype.
Read more >An Alternative Approach to JavaScript Error Handling
The cleanest way to handle errors is to use exceptions¹. Of course, a try-catch block is far more convenient than returning errors.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You are sending the messages to the window’s console, but that is different from the Node.js console. Try this instead:
In case this helps anyone else, in 3.1.1 I had to add the following to forward errors from event scripts (otherwise they go silently unnoticed):