11import { constants as osConstants } from 'node:os' ;
22import { cleanCoverageReports , createCoverageProvider } from '../coverage' ;
33import { createPool } from '../pool' ;
4- import type { EntryInfo , ProjectEntries , SourceMapInput } from '../types' ;
4+ import type {
5+ Duration ,
6+ EntryInfo ,
7+ PhaseTimings ,
8+ ProjectEntries ,
9+ SourceMapInput ,
10+ } from '../types' ;
511import type { CoverageMap } from '../types/coverage' ;
612import {
713 clearScreen ,
814 color ,
915 getTestEntries ,
1016 logger ,
17+ mergePhaseTimings ,
1118 resolveShardedEntries ,
1219} from '../utils' ;
1320import {
@@ -110,11 +117,7 @@ const notifyReportersOnTestRunEnd = async ({
110117} : {
111118 context : Rstest ;
112119 coverage ?: CoverageMap ;
113- duration : {
114- totalTime : number ;
115- buildTime : number ;
116- testTime : number ;
117- } ;
120+ duration : Duration ;
118121 getSourcemap : ( sourcePath : string ) => Promise < SourceMapInput | null > ;
119122 unhandledErrors ?: Error [ ] ;
120123 filterRerunTestPaths ?: string [ ] ;
@@ -460,6 +463,8 @@ export async function runTests(context: Rstest): Promise<void> {
460463 ? coverageProvider . createCoverageMap ( )
461464 : undefined ;
462465
466+ let phaseTimings : PhaseTimings | undefined ;
467+
463468 const returns = await Promise . all (
464469 projects . map ( async ( p ) => {
465470 const {
@@ -548,6 +553,9 @@ export async function runTests(context: Rstest): Promise<void> {
548553 project : p ,
549554 updateSnapshot : context . snapshotManager . options . updateSnapshot ,
550555 onCoverageResult : ( coverage ) => mergedCoverageMap ?. merge ( coverage ) ,
556+ onPhaseTimings : ( timings ) => {
557+ phaseTimings = mergePhaseTimings ( phaseTimings , timings ) ;
558+ } ,
551559 } ) ;
552560
553561 return {
@@ -599,7 +607,7 @@ export async function runTests(context: Rstest): Promise<void> {
599607 } ;
600608
601609 // When unifying reporter output, combine browser and node durations
602- const duration =
610+ const base =
603611 shouldUnifyReporter && browserResult
604612 ? {
605613 totalTime :
@@ -612,6 +620,7 @@ export async function runTests(context: Rstest): Promise<void> {
612620 buildTime,
613621 testTime,
614622 } ;
623+ const duration : Duration = { ...base , phaseTimings } ;
615624
616625 const results = returns . flatMap ( ( r ) => r . results ) ;
617626 const testResults = returns . flatMap ( ( r ) => r . testResults ) ;
0 commit comments