From a4ac9de0f69e93fb131562ffdad5e3ad0b858041 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 16 Sep 2024 16:09:04 -0500 Subject: [PATCH] fix: ensure that projects without optional chainer support can use @cypress/code-coverage (#881) --- support.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/support.js b/support.js index 384adafc..d6f427b6 100644 --- a/support.js +++ b/support.js @@ -71,8 +71,15 @@ const registerHooks = () => { // because we don't control the cross-origin code, we can safely return let applicationSourceCoverage try { - applicationSourceCoverage = win?.__coverage__ + // Note that we are purposefully not supporting the optional chaining syntax here to + // support a wide range of projects (some of which are not set up to support the optional + // chaining syntax due to current Cypress limitations). See: + // https://github.com/cypress-io/cypress/issues/20753 + if (win) { + applicationSourceCoverage = win.__coverage__ + } } catch {} + if (!applicationSourceCoverage) { return }