-
-
Notifications
You must be signed in to change notification settings - Fork 931
/
reportingExecutionTime.ts
55 lines (47 loc) · 1.15 KB
/
reportingExecutionTime.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { executionTimeLogger } from '@pnpm/core-loggers'
import { toOutput$ } from '@pnpm/default-reporter'
import { createStreamParser } from '@pnpm/logger'
import { take } from 'rxjs/operators'
test('does not print execution time for help command', (done) => {
const output$ = toOutput$({
context: {
argv: ['help'],
},
streamParser: createStreamParser(),
})
executionTimeLogger.debug({
startedAt: 1665279402859,
endedAt: 1665279413671,
})
const subscription = output$.subscribe({
complete: () => done(),
error: done,
next: () => {
done('should not log anything')
},
})
setTimeout(() => {
done()
subscription.unsubscribe()
}, 10)
})
test('prints execution time for install command', (done) => {
const output$ = toOutput$({
context: {
argv: ['install'],
},
streamParser: createStreamParser(),
})
executionTimeLogger.debug({
startedAt: 1665279402859,
endedAt: 1665279413671,
})
expect.assertions(1)
output$.pipe(take(1)).subscribe({
complete: () => done(),
error: done,
next: output => {
expect(output).toBe('Done in 10.8s')
},
})
})