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

Method changeNamePattern

packages/vitest/src/node/core.ts:1259–1279  ·  view source on GitHub ↗

@internal

(pattern: string, files: string[] = this.state.getFilepaths(), trigger?: string)

Source from the content-addressed store, hash-verified

1257
1258 /** @internal */
1259 async changeNamePattern(pattern: string, files: string[] = this.state.getFilepaths(), trigger?: string): Promise<void> {
1260 // Empty test name pattern should reset filename pattern as well
1261 if (pattern === '') {
1262 this.filenamePattern = undefined
1263 }
1264
1265 const testNamePattern = pattern ? new RegExp(pattern) : undefined
1266 this.configOverride.testNamePattern = testNamePattern
1267 // filter only test files that have tests matching the pattern
1268 if (testNamePattern) {
1269 files = files.filter((filepath) => {
1270 const files = this.state.getFiles([filepath])
1271 return !files.length || files.some((file) => {
1272 const tasks = getTasks(file)
1273 return !tasks.length || tasks.some(task => testNamePattern.test(task.name))
1274 })
1275 })
1276 }
1277
1278 await this.rerunFiles(files, trigger, pattern === '')
1279 }
1280
1281 /** @internal */
1282 async changeFilenamePattern(pattern: string, files: string[] = this.state.getFilepaths()): Promise<void> {

Callers 2

_keypressHandlerFunction · 0.80
inputNamePatternFunction · 0.80

Calls 6

rerunFilesMethod · 0.95
getTasksFunction · 0.90
filterMethod · 0.65
getFilepathsMethod · 0.45
getFilesMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected