code-coverage icon indicating copy to clipboard operation
code-coverage copied to clipboard

BREAKING: support specPattern, drop support for integrationFolder

Open lmiller1990 opened this issue 3 years ago • 0 comments

Via patch package.


Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @cypress/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@cypress/code-coverage/support-utils.js b/node_modules/@cypress/code-coverage/support-utils.js
index 31e00ee..0c56908 100644
--- a/node_modules/@cypress/code-coverage/support-utils.js
+++ b/node_modules/@cypress/code-coverage/support-utils.js
@@ -10,7 +10,7 @@ const filterSpecsFromCoverage = (totalCoverage, config = Cypress.config) => {
   const integrationFolder = config('integrationFolder')
   /** @type {string} Cypress run-time config has test files string pattern */
   // @ts-ignore
-  const testFilePattern = config('testFiles')
+  const testFilePattern = config('specPattern')
 
   // test files chould be:
   //  wild card string "**/*.*" (default)
diff --git a/node_modules/@cypress/code-coverage/support.js b/node_modules/@cypress/code-coverage/support.js
index c99ceb2..f51ce4e 100644
--- a/node_modules/@cypress/code-coverage/support.js
+++ b/node_modules/@cypress/code-coverage/support.js
@@ -37,7 +37,6 @@ const logMessage = (s) => {
  * If there are more files loaded from support folder, also removes them
  */
 const filterSupportFilesFromCoverage = (totalCoverage) => {
-  const integrationFolder = Cypress.config('integrationFolder')
   const supportFile = Cypress.config('supportFile')
 
   /** @type {string} Cypress run-time config has the support folder string */
@@ -50,16 +49,9 @@ const filterSupportFilesFromCoverage = (totalCoverage) => {
     isSupportFile(filename)
   )
 
-  // check the edge case
-  //   if we have files from support folder AND the support folder is not same
-  //   as the integration, or its prefix (this might remove all app source files)
-  //   then remove all files from the support folder
-  if (!integrationFolder.startsWith(supportFolder)) {
-    // remove all covered files from support folder
-    coverage = Cypress._.omitBy(totalCoverage, (fileCoverage, filename) =>
-      filename.startsWith(supportFolder)
-    )
-  }
+  coverage = Cypress._.omitBy(totalCoverage, (fileCoverage, filename) =>
+    filename.startsWith(supportFolder)
+  )
   return coverage
 }
 

This issue body was partially generated by patch-package.

lmiller1990 avatar Dec 03 '21 07:12 lmiller1990