Skip to content

fix: Fix error when testing cross-origin code #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 3, 2024
8 changes: 8 additions & 0 deletions support.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ const registerHooks = () => {
windowCoverageObjects = []

const saveCoverageObject = (win) => {
// accessing win.__coverage__ will error when testing cross-origin code
// because we don't control cross-origin code anyway, we can safely return
try {
win.__coverage__
} catch {
return
}

// if application code has been instrumented, the app iframe "window" has an object
const applicationSourceCoverage = win.__coverage__
if (!applicationSourceCoverage) {
Expand Down
Loading