-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Better error handling on no test code.
- Loading branch information
1 parent
c9884e8
commit ffab476
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { deepStrictEqual, ok } from 'node:assert' | ||
import { test } from 'node:test' | ||
import { isMainThread } from 'node:worker_threads' | ||
import { cronometro } from '../src/index.js' | ||
|
||
if (isMainThread) { | ||
test('Errors are properly handled when no tests are exported in the worker threads', async () => { | ||
const results = await cronometro( | ||
{ | ||
single() {}, | ||
multiple() {} | ||
}, | ||
{ iterations: 10, print: false } | ||
) | ||
|
||
ok(!results.single.success) | ||
ok(results.single.error instanceof Error) | ||
deepStrictEqual(results.single.error.message, 'No test code exported from the worker thread') | ||
deepStrictEqual(results.single.size, 0) | ||
deepStrictEqual(results.single.min, 0) | ||
deepStrictEqual(results.single.max, 0) | ||
deepStrictEqual(results.single.mean, 0) | ||
deepStrictEqual(results.single.stddev, 0) | ||
deepStrictEqual(results.single.standardError, 0) | ||
deepStrictEqual(results.single.percentiles, {}) | ||
|
||
ok(!results.multiple.success) | ||
ok(results.multiple.error instanceof Error) | ||
deepStrictEqual(results.multiple.error.message, 'No test code exported from the worker thread') | ||
deepStrictEqual(results.multiple.size, 0) | ||
deepStrictEqual(results.multiple.min, 0) | ||
deepStrictEqual(results.multiple.max, 0) | ||
deepStrictEqual(results.multiple.mean, 0) | ||
deepStrictEqual(results.multiple.stddev, 0) | ||
deepStrictEqual(results.multiple.standardError, 0) | ||
deepStrictEqual(results.multiple.percentiles, {}) | ||
}) | ||
} |