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

Method experimental_parseSpecification

packages/vitest/src/node/core.ts:1084–1109  ·  view source on GitHub ↗
(specification: TestSpecification)

Source from the content-addressed store, hash-verified

1082 }
1083
1084 public async experimental_parseSpecification(specification: TestSpecification): Promise<TestModule> {
1085 if (this.mode !== 'test') {
1086 throw new Error(`The \`experimental_parseSpecification\` does not support "${this.mode}" mode.`)
1087 }
1088 const file = await astCollectTests(specification.project, specification.moduleId).catch((error) => {
1089 return createFailedFileTask(specification.project, specification.moduleId, error)
1090 })
1091 const config = specification.project.config
1092 const hasOnly = someTasksAreOnly(file)
1093 const tagsFilter = this.config.tagsFilter
1094 ? createTagsFilter(this.config.tagsFilter, this.config.tags)
1095 : undefined
1096 interpretTaskModes(
1097 file,
1098 config.testNamePattern,
1099 specification.testLines,
1100 specification.testIds,
1101 tagsFilter,
1102 hasOnly,
1103 false,
1104 config.allowOnly,
1105 )
1106 // register in state, so it can be retrieved by "getReportedEntity"
1107 this.state.collectFiles(specification.project, [file])
1108 return this.state.getReportedEntity(file) as TestModule
1109 }
1110
1111 /**
1112 * Collect tests in specified modules. Vitest will run the files to collect tests.

Callers 2

collectTestModuleFunction · 0.80

Calls 7

astCollectTestsFunction · 0.90
createFailedFileTaskFunction · 0.90
someTasksAreOnlyFunction · 0.90
createTagsFilterFunction · 0.90
interpretTaskModesFunction · 0.90
getReportedEntityMethod · 0.80
collectFilesMethod · 0.45

Tested by 1

collectTestModuleFunction · 0.64