File tree Expand file tree Collapse file tree 4 files changed +34
-19
lines changed Expand file tree Collapse file tree 4 files changed +34
-19
lines changed Original file line number Diff line number Diff line change @@ -621,7 +621,7 @@ const test = async (
621621 'coverage.json' ,
622622 JSON . stringify ( {
623623 ...( countAsserts
624- ? JSON . parse ( await promises . readFile ( './tmp/assertion-summary .json' ) )
624+ ? JSON . parse ( await promises . readFile ( './tmp/counts .json' ) )
625625 : { } ) ,
626626 ...JSON . parse ( await promises . readFile ( './tmp/coverage-summary.json' ) )
627627 . total ,
@@ -784,4 +784,4 @@ export const prePublishPackage = series(
784784 testE2e ,
785785) ;
786786
787- export const publishPackage = series ( prePublishPackage , npmPublish ) ;
787+ export const publishPackage = series ( prePublishPackage , npmPublish ) ;
Original file line number Diff line number Diff line change 1+ import { writeFileSync } from 'fs' ;
12import { TestEnvironment } from 'jest-environment-jsdom' ;
23import { TextDecoder , TextEncoder } from 'util' ;
34import { BroadcastChannel } from 'worker_threads' ;
45
5- export default class extends TestEnvironment {
6- static assertionCalls = 0 ;
6+ export default class TinyBaseEnvironment extends TestEnvironment {
7+ static tests = 0 ;
8+ static assertions = 0 ;
9+
710 async setup ( ) {
811 Object . assign ( this . global , {
912 TextDecoder,
@@ -18,4 +21,16 @@ export default class extends TestEnvironment {
1821 } ) ;
1922 await super . setup ( ) ;
2023 }
24+
25+ async teardown ( ) {
26+ writeFileSync (
27+ './tmp/counts.json' ,
28+ JSON . stringify ( {
29+ tests : TinyBaseEnvironment . tests ,
30+ assertions : TinyBaseEnvironment . assertions ,
31+ } ) ,
32+ 'utf-8' ,
33+ ) ;
34+ await super . teardown ( ) ;
35+ }
2136}
Original file line number Diff line number Diff line change 1- import env from './environment.js' ;
2- import { writeFileSync } from 'fs' ;
1+ import { readFileSync } from 'fs' ;
32
43export default class {
5- onRunComplete ( _contexts , results ) {
6- writeFileSync (
7- './tmp/assertion-summary.json' ,
8- JSON . stringify ( {
9- tests : results . numTotalTests ,
10- assertions : env . assertionCalls ,
11- } ) ,
12- 'utf-8' ,
13- ) ;
4+ onRunComplete ( ) {
5+ const counts = JSON . parse ( readFileSync ( './tmp/counts.json' , 'utf-8' ) ) ;
146 // eslint-disable-next-line no-console
15- console . log ( 'Assertions:' , env . assertionCalls , '\n' ) ;
7+ console . log (
8+ 'Tests:' ,
9+ counts . tests ,
10+ '\nAssertions:' ,
11+ counts . assertions ,
12+ '\n' ,
13+ ) ;
1614 }
1715}
Original file line number Diff line number Diff line change 11jest . retryTimes ( 10 ) ;
22
3- afterEach (
4- ( ) => ( global . env . assertionCalls += expect . getState ( ) . assertionCalls ) ,
5- ) ;
3+ afterEach ( ( ) => {
4+ const { assertionCalls} = expect . getState ( ) ;
5+ global . env . tests += 1 ;
6+ global . env . assertions += assertionCalls ;
7+ } ) ;
You can’t perform that action at this time.
0 commit comments