How do I test that Sentry is reporting errors?

The browser console can not be used as it is sandboxed. A simple trick is to attach the code to an HTML element like this:

<h1 onClick="throw new Error('Test')">
  My Website
</h1>

And click on the heading afterwards.

This can be done in the browser inspector and so your source code doesn't have to be modified.


One way to generate an error in Sentry is to call a function that is not defined.

Note: This cannot be done in the console - it must be in the code.

Try adding this to your code (taken from the docs):

myUndefinedFunction();

If your code build doesn't allow this due to tests/linting you might be able to use:

window.myUndefinedFunction()

You should then see error in your browser console and in the Sentry dashboard.

Have a read of the Docs for more info.


Verify (newer)

myUndefinedFunction();

Verifying Your Setup (older)

Sentry.captureException(new Error("This is my fake error message"));

https://docs.sentry.io/platforms/javascript/?platform=browser#verifying-your-setup

May be worth double-checking your setup (or updating) and config too.