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

Function runSuite

packages/runner/src/run.ts:837–974  ·  view source on GitHub ↗
(suite: Suite, runner: VitestRunner)

Source from the content-addressed store, hash-verified

835}
836
837export async function runSuite(suite: Suite, runner: VitestRunner): Promise<void> {
838 await runner.onBeforeRunSuite?.(suite)
839
840 if (suite.result?.state === 'fail') {
841 markTasksAsSkipped(suite, runner)
842 // failed during collection
843 updateTask('suite-failed-early', suite, runner)
844 return
845 }
846
847 const start = now()
848
849 const mode = suite.mode
850
851 suite.result = {
852 state: mode === 'skip' || mode === 'todo' ? mode : 'run',
853 startTime: unixNow(),
854 }
855 const $ = runner.trace!
856
857 updateTask('suite-prepare', suite, runner)
858
859 let beforeAllCleanups: unknown[] = []
860
861 if (suite.mode === 'skip') {
862 suite.result.state = 'skip'
863
864 updateTask('suite-finished', suite, runner)
865 }
866 else if (suite.mode === 'todo') {
867 suite.result.state = 'todo'
868
869 updateTask('suite-finished', suite, runner)
870 }
871 else {
872 let suiteRan = false
873
874 try {
875 await callAroundAllHooks(suite, async () => {
876 suiteRan = true
877 try {
878 // beforeAll
879 try {
880 beforeAllCleanups = await $('suite.beforeAll', () => callSuiteHook(
881 suite,
882 suite,
883 'beforeAll',
884 runner,
885 [suite],
886 ))
887 }
888 catch (e) {
889 failTask(suite.result!, e, runner.config.diffOptions)
890 markTasksAsSkipped(suite, runner)
891 return
892 }
893
894 // run suite children

Callers 3

runSuiteChildFunction · 0.85
runFilesFunction · 0.85

Calls 15

partitionSuiteChildrenFunction · 0.90
limitConcurrencyFunction · 0.90
callFixtureCleanupFunction · 0.90
hasTestsFunction · 0.90
processErrorFunction · 0.90
hasFailedFunction · 0.90
markTasksAsSkippedFunction · 0.85
callAroundAllHooksFunction · 0.85
callSuiteHookFunction · 0.85
failTaskFunction · 0.85
runSuiteChildFunction · 0.85
shuffleFunction · 0.85

Tested by

no test coverage detected