- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Closed
Description
Problem Statement
Currently, it's quite annoying to just throw an error in a browser integration test and to check for the resulting payload. The intuitive way would be to just top-level call throw new Error() in subject.js. However, the resulting error gets thrown as a "Script Error" because it's thrown synchronously when the subject bundle JS is evaluated by the browser. This error is filtered by the SDK by default for good reason.
Solution Brainstorm
Ideally, we can work around this in one way or another so that we can have a simple way of throwing errors in a test that actually make it through the SDK. I have a couple of ideas but we'd need to check what the best approach is. Also I'm definitely open to other ideas.
- wrap subject.jscode in asetTimeoutcall. This will cause the initial bundle evaluation to succeed and potential errors should be thrown as intended by testers.
- let the test framework accept another file (e.g. async-subject.js) that does what's suggested in 1.subject.jswould stay sync as previously.
- we could just create a test utility (e.g. triggerError(err: unkown)) that callspage.evaluate. This should work 🤔 but admittedly I didn't test it yet