Releases: Gigabyte5671/micro-test-runner
Releases · Gigabyte5671/micro-test-runner
Version 2.0.1
- Improve the readability of logs:
If the expected value is a string containing a line break, the expected and received values will be printed on the line following the "Expected:"/"Received:". - Updated development dependencies.
Version 2.0.0
Note
This version contains various breaking changes.
- For consistency, the
expect()
method now always returns a promise. Because of this, theasync()
method has been removed. Micro Test-Runner now gracefully handles both sync and async candidates automatically. - Logs are now much clearer, and include the expected vs received result when a test fails.
- The
logging()
method now accepts string options forseverity
andperformance
. You no longer need to importFailureLogSeverity
if you want to use automatic error logging. For example:.logging('Awesome', 'error', ['✓', '✕'], 'table')
- The
with()
method now accepts a simple list of arguments, instead of an array. For example:.with(foo, 'bar', 'baz')
- This is the same for the
expect()
method:.expect(foo, 5, (value) => value + 1 === 7)
- Type hints for arguments and results have been added. TypeScript will now inform you of any type mismatches between
test()
,with()
, andexpect()
. For example:function isEven(a: number): boolean { return a % 2 === 0; } test(isEven) .with('foo') // TS: ^ Argument of type 'string' is not assignable to parameter of type 'number'. .expect(24) // TS: ^ Argument of type 'number' is not assignable to parameter of type 'boolean'.
Version 1.5.3
Updated and clarified the documentation based on some helpful feedback.
Version 1.5.2
Added my funding link to the package ❤️
Version 1.5.1
Minified the distribution files so that Micro Test-Runner is 28% smaller when unpacked.
Version 1.5.0
- Simplified the test logic and reduced duplicated code to keep Micro Test-Runner small and fast.
- Updated the behaviour of
.expect()
so that a single condition can be used to check the result of multiple tests. - When using a function to evaluate test results, along with the run result the function will now also receive the run index (
number
) and run duration (number
, ms). - Micro Test-Runner can now measure and log the performance of the candidate. For example:
test(slowFunction) // Test `slowFunction`...
.times(3) // 3 times...
.logging('Slow', FailureLogSeverity.LOG, undefined, 'table') // Logging the outcome and performance to a table in the console...
.with([2, 3]) // With these arguments...
.with([4, 1]) // And these arguments...
.expect([(value, runIndex, duration) => { // And expect these results (verifying them with a function).
return
value === 5 // Check the value returned by `slowFunction`.
&& duration < 200; // Check that `slowFunction` took less than 200ms.
}]);
/* Console output...
✓ Slow test passed in 1004.742ms (x̄ 160.779ms per run, over 6 runs):
╭──────┬───────┬───────────────╮
│ Test │ Run │ Duration (ms) │
├──────┼───────┼───────────────┤
│ 1 │ 1 │ 150.812 │
│ │ 2 │ 184.766 │
│ │ 3 │ 161.057 │
├──────┼───────┼───────────────┤
│ 2 │ 1 │ 162.936 │
│ │ 2 │ 159.213 │
│ │ 3 │ 145.887 │
╰──────┴───────┴───────────────╯
*/
Version 1.4.0
- On some synchronous tests, the result evaluation was being carried out before the test completed. This has been fixed.
- Micro Test-Runner is now compiled as an ES Module. Depending on your project configuration, you may no longer need to invoke the test-runner with
test.default()
. - Micro Test-Runner can now automatically handle logging of test results with the
.logging()
method:
import test, { FailureLogSeverity } from 'micro-test-runner';
test(yourFunction) // Test `yourFunction`...
.times(3) // 3 times...
.logging('Function Name', FailureLogSeverity.WARN) // Logging the result...
.with(['Hello', 'world!']) // With these arguments...
.expect(['Hello world!']); // And expect these results.
Version 1.3.1
Include correct build files.
Version 1.3.0
- Intellisense should now show
MicroTestRunner<'sync'>
and'async'
instead ofMicroTestRunner<false>
andtrue
. - A context can now be passed to the candidate function by chaining the
.context()
method.
Version 1.2.0
Candidate functions can now be run asynchronously by chaining the test with the .async()
modifier method:
const result = await test(apiCall) // Test your `apiCall` function...
.async() // Asynchronously...
.times(3) // 3 times...
.with(['https://example.com/api', '/endpoint']) // With these arguments...
.expect([{ data: 'Hello world!' }]); // And expect these results.