Skip to content

Improve error throwing behaviour in browser integration test  #11678

@Lms24

Description

@Lms24

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.

  1. wrap subject.js code in a setTimeout call. This will cause the initial bundle evaluation to succeed and potential errors should be thrown as intended by testers.
  2. let the test framework accept another file (e.g. async-subject.js) that does what's suggested in 1. subject.js would stay sync as previously.
  3. we could just create a test utility (e.g. triggerError(err: unkown)) that calls page.evaluate. This should work 🤔 but admittedly I didn't test it yet

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions