From d2dadd9c984e807eda4e3b2ca0e7b829fa0e9eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 29 Mar 2024 10:02:42 +0100 Subject: [PATCH] fix coverage --- src/Behat/JsCoverageContextTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Behat/JsCoverageContextTrait.php b/src/Behat/JsCoverageContextTrait.php index 6327934b6f..eecc6b95c7 100644 --- a/src/Behat/JsCoverageContextTrait.php +++ b/src/Behat/JsCoverageContextTrait.php @@ -48,7 +48,7 @@ protected function saveJsCoverage(): void throw new Error('"window.__coverage__" is not defined'); } - const transformCoverageFx = function (istanbulCoverage) { + const transformCoverageFx = function (istanbulCoverage, seenPaths) { const res = {}; Object.entries(istanbulCoverage).forEach(([path, data]) => { const resSingle = {}; @@ -74,7 +74,7 @@ protected function saveJsCoverage(): void if (window.__coverage_beforeunload__ !== true) { window.addEventListener('beforeunload', () => { const navigateCoverages = JSON.parse(window.sessionStorage.getItem('__coverage_navigate__') ?? '[]'); - navigateCoverages.push(transformCoverageFx(window.__coverage__)); + navigateCoverages.push(transformCoverageFx(window.__coverage__, new Set())); window.sessionStorage.setItem('__coverage_navigate__', JSON.stringify(navigateCoverages)); }); window.__coverage_beforeunload__ = true; @@ -84,7 +84,7 @@ protected function saveJsCoverage(): void const res = []; for (const coverage of [windowCoverage, ...navigateCoverages]) { - res.push(transformCoverageFx(coverage)); + res.push(transformCoverageFx(coverage, seenPaths)); } return res;