-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb71a9c
commit 61b54a6
Showing
4 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { TestResult } from "@jest/test-result"; | ||
|
||
export const phaseOrder = [ | ||
'runTest', | ||
'writeToFifo', | ||
'fork', | ||
// 'handleTestRes', | ||
// 'writeResult', | ||
'innerRunTest', | ||
'readTestResult', | ||
] as const; | ||
|
||
type Phases = typeof phaseOrder[number]; | ||
|
||
// const _allTimings: any[] = [] | ||
// const PREFIX = '____¬timings¬' | ||
// const SUFFIX = '¬end¬\n' | ||
|
||
// export const getAllTimings = () => _allTimings | ||
|
||
// export function handleStderr(chunk: string) { | ||
// const start = chunk.indexOf(PREFIX); | ||
// if (start === -1) { | ||
// return chunk | ||
// } | ||
|
||
// const end = chunk.indexOf(SUFFIX); | ||
// if (end ===-1) { | ||
// console.error('should not happen, size is small so should be atomic') | ||
// return chunk | ||
// } | ||
// let left = chunk.slice(0, start) + chunk.slice(end+SUFFIX.length) | ||
// _allTimings.push(JSON.parse(chunk.slice(PREFIX.length, end))) | ||
// return left | ||
// } | ||
|
||
export type Timing = ReturnType<typeof createTimings> | ||
|
||
export const createTimings = () => { | ||
const allTimings: any[] = [] | ||
const time = (phase: Phases, type: 'start' | 'end') => { | ||
allTimings.push({phase, type, time: Date.now()}) | ||
} | ||
const enrich = (res: TestResult) => { | ||
res.perfStats = { | ||
...(res.perfStats ?? {}), | ||
//@ts-ignore | ||
timings: [...(res.perfStats.timings ?? []), ...allTimings] | ||
} | ||
return res | ||
} | ||
|
||
return {time, enrich} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters