Skip to content

Commit 32e5bbc

Browse files
avivkelleraduh95
authored andcommitted
benchmark: add test-reporters
PR-URL: #55757 Refs: #55723 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Raz Luvaton <rluvaton@gmail.com>
1 parent 1b863b9 commit 32e5bbc

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const{ test }=require('node:test');
2+
3+
test('should pass',()=>{});
4+
test('should fail',()=>{thrownewError('fail');});
5+
test('should skip',{skip: true},()=>{});
6+
test('parent',(t)=>{
7+
t.test('should fail',()=>{thrownewError('fail');});
8+
t.test('should pass but parent fail',(t,done)=>{
9+
setImmediate(done);
10+
});
11+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
const{ run }=require('node:test');
5+
constreporters=require('node:test/reporters');
6+
const{ Readable }=require('node:stream');
7+
constassert=require('node:assert');
8+
9+
constbench=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+
conststream=run({
17+
files: ['../fixtures/basic-test-runner.js'],
18+
});
19+
lettestResults;
20+
21+
asyncfunctionmain({ n,reporter: r}){
22+
testResults??=awaitstream.toArray();
23+
24+
// Create readable streams for each iteration
25+
constreadables=Array.from({length: n},()=>Readable.from(testResults));
26+
27+
// Get the selected reporter
28+
constreporter=reporters[r];
29+
30+
bench.start();
31+
32+
letnoDead;
33+
for(constreadableofreadables){
34+
// Process each readable stream through the reporter
35+
noDead=awaitreadable.compose(reporter).toArray();
36+
}
37+
38+
bench.end(n);
39+
40+
assert.ok(noDead);
41+
}

0 commit comments

Comments
 (0)