Skip to content

Commit 0f417be

Browse files
committed
fix: fix error handling in .table()
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
1 parent c078860 commit 0f417be

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
"import": "./dist/index.js"
4040
}
4141
},
42-
"files": ["dist/**"],
42+
"files": [
43+
"dist/**"
44+
],
4345
"repository": "tinylibs/tinybench",
4446
"license": "MIT",
4547
"devDependencies": {
@@ -65,5 +67,9 @@
6567
"typescript": "~5.6.3",
6668
"vitest": "^2.1.5"
6769
},
68-
"keywords": ["benchmark", "tinylibs", "tiny"]
70+
"keywords": [
71+
"benchmark",
72+
"tinylibs",
73+
"tiny"
74+
]
6975
}

src/bench.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ export class Bench extends EventTarget {
233233
Error: task.result.error.message,
234234
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
235235
Stack: task.result.error.stack!,
236-
// eslint-disable-next-line perfectionist/sort-objects
237-
Samples: task.result.latency.samples.length,
238236
}
239237
: (convert?.(task) ?? {
240238
'Task name': task.name,

test/index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ test('bench table', async () => {
6464
Samples: expect.any(Number),
6565
},
6666
])
67+
68+
bench.remove('foo')
69+
bench.add('bar', () => {
70+
throw new Error('fake')
71+
})
72+
73+
await bench.run()
74+
75+
expect(bench.table()).toStrictEqual([
76+
{
77+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
78+
'Task name': expect.any(String),
79+
// eslint-disable-next-line perfectionist/sort-objects, @typescript-eslint/no-unsafe-assignment
80+
Error: expect.any(String),
81+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
82+
Stack: expect.any(String),
83+
},
84+
])
6785
})
6886

6987
test('bench task runs and time consistency', async () => {

0 commit comments

Comments
 (0)