1+ import fs from 'node:fs' ;
2+
3+
4+ export default class CEEReporter {
5+
6+ results = { } ;
7+
8+ onTestEnd ( test , result ) {
9+ const [ _ , _browser , _file , framework , suite ] = test . titlePath ( ) ;
10+ ( ( this . results [ framework ] ||= { } ) [ suite ] ||= { } ) [ result . status ] ||= 0
11+ this . results [ framework ] [ suite ] [ result . status ] += 1 ;
12+ const weight = test . annotations . filter ( ( { type} ) => type === 'weight' ) . toReversed ( ) [ 0 ] ?. description ?? 3 ;
13+ ( this . results [ framework ] . weight ||= { } ) [ result . status ] ||= 0 ;
14+ this . results [ framework ] . weight [ result . status ] += weight
15+ }
16+
17+ onEnd ( result ) {
18+ for ( const [ framework , results ] of Object . entries ( this . results ) ) {
19+ const basicPassed = results [ 'basic support' ] . passed ?? 0 ;
20+ const basicFailed = results [ 'basic support' ] . failed ?? 0 ;
21+ const advancedPassed = results [ 'advanced support' ] . passed ?? 0 ;
22+ const advancedFailed = results [ 'advanced support' ] . failed ?? 0 ;
23+
24+ const weightedPassed = results . weight . passed ?? 0 ;
25+ const weightedFailed = results . weight . failed ?? 0 ;
26+ const totalWeight = weightedPassed + weightedFailed ;
27+
28+ fs . writeFileSync ( `../../${ framework } /results/results.json` , JSON . stringify ( {
29+ summary : {
30+ success : basicPassed + advancedPassed ,
31+ failed : basicFailed + advancedFailed ,
32+ score : totalWeight === 0 ? 0 : 100 * weightedPassed / totalWeight ,
33+ basicSupport : {
34+ total : basicPassed + basicFailed ,
35+ failed : basicFailed ,
36+ passed : basicPassed
37+ } ,
38+ advancedSupport : {
39+ total : advancedPassed + advancedFailed ,
40+ failed : advancedFailed ,
41+ passed : advancedPassed
42+ }
43+ }
44+ } , null , 2 ) )
45+ }
46+ }
47+ }
0 commit comments