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

Function collectTestModule

test/cli/test/static-collect.test.ts:1654–1685  ·  view source on GitHub ↗
(code: string, options?: CliOptions)

Source from the content-addressed store, hash-verified

1652})
1653
1654async function collectTestModule(code: string, options?: CliOptions) {
1655 const vitest = await createVitest(
1656 'test',
1657 {
1658 config: false,
1659 includeTaskLocation: true,
1660 allowOnly: true,
1661 ...options,
1662 tags: [
1663 { name: 'slow' },
1664 { name: 'integration' },
1665 { name: 'unit' },
1666 ],
1667 },
1668 {
1669 plugins: [
1670 {
1671 name: 'ast-collect-test',
1672 load(id) {
1673 if (id === 'simple.test.ts') {
1674 return code
1675 }
1676 },
1677 },
1678 ],
1679 },
1680 )
1681 onTestFinished(() => vitest.close())
1682 return vitest.experimental_parseSpecification(
1683 vitest.getRootProject().createSpecification('simple.test.ts'),
1684 )
1685}
1686
1687async function collectTests(code: string, options?: CliOptions & { fnFn?: boolean }) {
1688 return testTree(await collectTestModule(code, options), {}, options?.fnFn)

Callers 2

collectTestsFunction · 0.85

Calls 5

createVitestFunction · 0.90
createSpecificationMethod · 0.80
getRootProjectMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected