I tried to use self.reportError(e) but it said that self is not defined (I'm running tests)
I then tried globalThis.reportError(e) and now it says "TypeError: globalThis.reportError is not a function"
I'm trying to call the global method reportError
https://developer.mozilla.org/en-US/docs/Web/API/reportError
Thanks to help provided in the comments, I realized reportError is not available for NodeJS, only in browsers.
See also:
https://github.com/nodejs/node/issues/38947