Skip to content
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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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