File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ const { test } = require ( 'node:test' ) ;
2+
3+ test ( 'should pass' , ( ) => { } ) ;
4+ test ( 'should fail' , ( ) => { throw new Error ( 'fail' ) ; } ) ;
5+ test ( 'should skip' , { skip : true } , ( ) => { } ) ;
6+ test ( 'parent' , ( t ) => {
7+ t . test ( 'should fail' , ( ) => { throw new Error ( 'fail' ) ; } ) ;
8+ t . test ( 'should pass but parent fail' , ( t , done ) => {
9+ setImmediate ( done ) ;
10+ } ) ;
11+ } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common' ) ;
4+ const { run } = require ( 'node:test' ) ;
5+ const reporters = require ( 'node:test/reporters' ) ;
6+ const { Readable } = require ( 'node:stream' ) ;
7+ const assert = require ( 'node:assert' ) ;
8+
9+ const bench = common . createBenchmark ( main , {
10+ n : [ 1e4 ] ,
11+ reporter : Object . keys ( reporters ) ,
12+ } ) ;
13+
14+ // No need to run this for every benchmark,
15+ // it should always be the same data.
16+ const stream = run ( {
17+ files : [ '../fixtures/basic-test-runner.js' ] ,
18+ } ) ;
19+ let testResults ;
20+
21+ async function main ( { n, reporter : r } ) {
22+ testResults ??= await stream . toArray ( ) ;
23+
24+ // Create readable streams for each iteration
25+ const readables = Array . from ( { length : n } , ( ) => Readable . from ( testResults ) ) ;
26+
27+ // Get the selected reporter
28+ const reporter = reporters [ r ] ;
29+
30+ bench . start ( ) ;
31+
32+ let noDead ;
33+ for ( const readable of readables ) {
34+ // Process each readable stream through the reporter
35+ noDead = await readable . compose ( reporter ) . toArray ( ) ;
36+ }
37+
38+ bench . end ( n ) ;
39+
40+ assert . ok ( noDead ) ;
41+ }
You can’t perform that action at this time.
0 commit comments