1
1
import type { TestSpecification } from 'vitest/node'
2
2
import { expect , test } from 'vitest'
3
- import { readCoverageMap , runVitest } from '../utils'
3
+ import { formatSummary , isV8Provider , readCoverageMap , runVitest } from '../utils'
4
4
5
5
const pools = [ 'forks' ]
6
6
@@ -28,7 +28,7 @@ for (const isolate of [true, false]) {
28
28
29
29
coverage : {
30
30
all : false ,
31
- reporter : [ 'json' , 'html' ] ,
31
+ reporter : 'json' ,
32
32
} ,
33
33
34
34
browser : {
@@ -37,18 +37,47 @@ for (const isolate of [true, false]) {
37
37
} )
38
38
39
39
const coverageMap = await readCoverageMap ( )
40
-
41
40
const branches = coverageMap . fileCoverageFor ( '<process-cwd>/fixtures/src/branch.ts' )
42
- expect ( branches . toSummary ( ) . lines . pct ) . toBe ( 100 )
43
- expect ( branches . toSummary ( ) . statements . pct ) . toBe ( 100 )
44
- expect ( branches . toSummary ( ) . functions . pct ) . toBe ( 100 )
45
- expect ( branches . toSummary ( ) . branches . pct ) . toBe ( 100 )
46
-
47
41
const math = coverageMap . fileCoverageFor ( '<process-cwd>/fixtures/src/math.ts' )
48
- expect ( math . toSummary ( ) . lines . pct ) . toBe ( 100 )
49
- expect ( math . toSummary ( ) . statements . pct ) . toBe ( 100 )
50
- expect ( math . toSummary ( ) . functions . pct ) . toBe ( 100 )
51
- expect ( math . toSummary ( ) . branches . pct ) . toBe ( 100 )
42
+
43
+ const summary = {
44
+ [ branches . path ] : formatSummary ( branches . toSummary ( ) ) ,
45
+ [ math . path ] : formatSummary ( math . toSummary ( ) ) ,
46
+ }
47
+
48
+ if ( isV8Provider ( ) ) {
49
+ expect ( summary ) . toStrictEqual ( {
50
+ '<process-cwd>/fixtures/src/branch.ts' : {
51
+ branches : '3/3 (100%)' ,
52
+ functions : '1/1 (100%)' ,
53
+ lines : '6/6 (100%)' ,
54
+ statements : '6/6 (100%)' ,
55
+ } ,
56
+ '<process-cwd>/fixtures/src/math.ts' : {
57
+ branches : '4/4 (100%)' ,
58
+ functions : '4/4 (100%)' ,
59
+ lines : '12/12 (100%)' ,
60
+ statements : '12/12 (100%)' ,
61
+ } ,
62
+ } )
63
+ }
64
+ else {
65
+ expect ( summary ) . toStrictEqual ( {
66
+ '<process-cwd>/fixtures/src/branch.ts' : {
67
+ branches : '2/2 (100%)' ,
68
+ functions : '1/1 (100%)' ,
69
+ lines : '4/4 (100%)' ,
70
+ statements : '4/4 (100%)' ,
71
+ } ,
72
+ '<process-cwd>/fixtures/src/math.ts' : {
73
+ branches : '0/0 (100%)' ,
74
+ functions : '4/4 (100%)' ,
75
+ lines : '4/4 (100%)' ,
76
+ statements : '4/4 (100%)' ,
77
+ } ,
78
+ } ,
79
+ )
80
+ }
52
81
} )
53
82
}
54
83
}
0 commit comments