Skip to content

Commit a4ac9de

Browse files
fix: ensure that projects without optional chainer support can use @cypress/code-coverage (#881)
1 parent 207b027 commit a4ac9de

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

support.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,15 @@ const registerHooks = () => {
7171
// because we don't control the cross-origin code, we can safely return
7272
let applicationSourceCoverage
7373
try {
74-
applicationSourceCoverage = win?.__coverage__
74+
// Note that we are purposefully not supporting the optional chaining syntax here to
75+
// support a wide range of projects (some of which are not set up to support the optional
76+
// chaining syntax due to current Cypress limitations). See:
77+
// https://github.com/cypress-io/cypress/issues/20753
78+
if (win) {
79+
applicationSourceCoverage = win.__coverage__
80+
}
7581
} catch {}
82+
7683
if (!applicationSourceCoverage) {
7784
return
7885
}

0 commit comments

Comments
 (0)