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

Function initSuite

packages/runner/src/suite.ts:491–536  ·  view source on GitHub ↗
(includeLocation: boolean)

Source from the content-addressed store, hash-verified

489 }
490
491 function initSuite(includeLocation: boolean) {
492 if (typeof suiteOptions === 'number') {
493 suiteOptions = { timeout: suiteOptions }
494 }
495
496 const currentSuite = collectorContext.currentSuite?.suite
497 const parentTask = currentSuite ?? collectorContext.currentSuite?.file
498 const suiteTags = toArray(suiteOptions?.tags)
499 validateTags(runner.config, suiteTags)
500
501 suite = {
502 id: '',
503 type: 'suite',
504 name,
505 fullName: createTaskName([
506 currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName,
507 name,
508 ]),
509 fullTestName: createTaskName([currentSuite?.fullTestName, name]),
510 suite: currentSuite,
511 mode,
512 each,
513 file: (currentSuite?.file ?? collectorContext.currentSuite?.file)!,
514 shuffle: suiteOptions?.shuffle,
515 tasks: [],
516 meta: suiteOptions?.meta ?? Object.create(null),
517 concurrent: suiteOptions?.concurrent,
518 tags: unique([...parentTask?.tags || [], ...suiteTags]),
519 }
520
521 if (runner && includeLocation && runner.config.includeTaskLocation) {
522 const limit = Error.stackTraceLimit
523 Error.stackTraceLimit = 15
524 const error = new Error('stacktrace').stack!
525 Error.stackTraceLimit = limit
526 const stack = findTestFileStackTrace(currentTestFilepath, error)
527 if (stack) {
528 suite.location = {
529 line: stack.line,
530 column: stack.column,
531 }
532 }
533 }
534
535 setHooks(suite, createSuiteHooks())
536 }
537
538 function clear() {
539 tasks.length = 0

Callers 2

createSuiteCollectorFunction · 0.85
clearFunction · 0.85

Calls 8

toArrayFunction · 0.90
validateTagsFunction · 0.90
createTaskNameFunction · 0.90
uniqueFunction · 0.90
findTestFileStackTraceFunction · 0.90
setHooksFunction · 0.90
createSuiteHooksFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected