MCPcopy
hub / github.com/vitest-dev/vitest / isIncluded

Method isIncluded

packages/vitest/src/node/coverage.ts:149–182  ·  view source on GitHub ↗

* Check if file matches `coverage.include` but not `coverage.exclude`

(_filename: string, root?: string)

Source from the content-addressed store, hash-verified

147 * Check if file matches `coverage.include` but not `coverage.exclude`
148 */
149 isIncluded(_filename: string, root?: string): boolean {
150 const roots = root ? [root] : this.roots
151
152 const filename = slash(cleanUrl(_filename))
153 const cacheHit = this.globCache.get(filename)
154
155 if (cacheHit !== undefined) {
156 return cacheHit
157 }
158
159 // File outside project root with default allowExternal
160 if (this.options.allowExternal === false && roots.every(root => !filename.startsWith(root))) {
161 this.globCache.set(filename, false)
162
163 return false
164 }
165
166 // By default `coverage.include` matches all files, except "coverage.exclude"
167 const glob = this.options.include || '**'
168
169 let included = pm.isMatch(filename, glob, {
170 contains: true,
171 dot: true,
172 ignore: this.options.exclude,
173 })
174
175 if (included && this.changedFiles) {
176 included = this.changedFiles.includes(filename)
177 }
178
179 this.globCache.set(filename, included)
180
181 return included
182 }
183
184 private async getUntestedFilesByRoot(
185 testedFiles: string[],

Callers 5

requiresTransformMethod · 0.80
generateCoverageMethod · 0.80
generateCoverageMethod · 0.80
convertCoverageMethod · 0.80

Calls 4

slashFunction · 0.90
cleanUrlFunction · 0.90
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected