Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c67aec3

Browse filesBrowse files
avivkellerruyadorno
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 b3ea42d commit c67aec3
Copy full SHA for c67aec3

2 files changed

+52Lines changed: 52 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+11Lines 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+
});
Collapse file
+41Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.