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

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
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', () => { 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+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy