|
| 1 | +// helper functions to use from "task.js" plugins code |
| 2 | +// that need access to the file system |
| 3 | + |
1 | 4 | // @ts-check |
2 | 5 | /// <reference types="cypress" /> |
3 | 6 | const { readFileSync, writeFileSync, existsSync } = require('fs') |
@@ -26,65 +29,6 @@ function checkAllPathsNotFound(nycFilename) { |
26 | 29 | return allFilesAreMissing |
27 | 30 | } |
28 | 31 |
|
29 | | -/** |
30 | | - * remove coverage for the spec files themselves, |
31 | | - * only keep "external" application source file coverage |
32 | | - */ |
33 | | -const filterSpecsFromCoverage = (totalCoverage, config = Cypress.config) => { |
34 | | - const integrationFolder = config('integrationFolder') |
35 | | - // @ts-ignore |
36 | | - const testFilePattern = config('testFiles') |
37 | | - |
38 | | - // test files chould be: |
39 | | - // wild card string "**/*.*" (default) |
40 | | - // wild card string "**/*spec.js" |
41 | | - // list of wild card strings or names ["**/*spec.js", "spec-one.js"] |
42 | | - const testFilePatterns = Array.isArray(testFilePattern) |
43 | | - ? testFilePattern |
44 | | - : [testFilePattern] |
45 | | - |
46 | | - const isUsingDefaultTestPattern = testFilePattern === '**/*.*' |
47 | | - |
48 | | - const isTestFile = filename => { |
49 | | - const matchedPattern = testFilePatterns.some(specPattern => |
50 | | - Cypress.minimatch(filename, specPattern) |
51 | | - ) |
52 | | - const matchedEndOfPath = testFilePatterns.some(specPattern => |
53 | | - filename.endsWith(specPattern) |
54 | | - ) |
55 | | - return matchedPattern || matchedEndOfPath |
56 | | - } |
57 | | - |
58 | | - const isInIntegrationFolder = filename => |
59 | | - filename.startsWith(integrationFolder) |
60 | | - |
61 | | - const isA = (fileCoverge, filename) => isInIntegrationFolder(filename) |
62 | | - const isB = (fileCoverge, filename) => isTestFile(filename) |
63 | | - |
64 | | - const isTestFileFilter = isUsingDefaultTestPattern ? isA : isB |
65 | | - |
66 | | - const coverage = Cypress._.omitBy(totalCoverage, isTestFileFilter) |
67 | | - return coverage |
68 | | -} |
69 | | - |
70 | | -/** |
71 | | - * Replace source-map's path by the corresponding absolute file path |
72 | | - * (coverage report wouldn't work with source-map path being relative |
73 | | - * or containing Webpack loaders and query parameters) |
74 | | - */ |
75 | | -function fixSourcePathes(coverage) { |
76 | | - Object.values(coverage).forEach(file => { |
77 | | - const { path: absolutePath, inputSourceMap } = file |
78 | | - const fileName = /([^\/\\]+)$/.exec(absolutePath)[1] |
79 | | - if (!inputSourceMap || !fileName) return |
80 | | - |
81 | | - if (inputSourceMap.sourceRoot) inputSourceMap.sourceRoot = '' |
82 | | - inputSourceMap.sources = inputSourceMap.sources.map(source => |
83 | | - source.includes(fileName) ? absolutePath : source |
84 | | - ) |
85 | | - }) |
86 | | -} |
87 | | - |
88 | 32 | /** |
89 | 33 | * A small debug utility to inspect paths saved in NYC output JSON file |
90 | 34 | */ |
@@ -251,8 +195,6 @@ function tryFindingLocalFiles(nycFilename) { |
251 | 195 | } |
252 | 196 |
|
253 | 197 | module.exports = { |
254 | | - fixSourcePathes, |
255 | | - filterSpecsFromCoverage, |
256 | 198 | showNycInfo, |
257 | 199 | resolveRelativePaths, |
258 | 200 | checkAllPathsNotFound, |
|
0 commit comments