Skip to content

Releases: Gigabyte5671/micro-test-runner

Version 2.0.1

03 Dec 20:21
Compare
Choose a tag to compare
  • 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

30 Oct 09:31
Compare
Choose a tag to compare

Note

This version contains various breaking changes.

  • For consistency, the expect() method now always returns a promise. Because of this, the async() 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 for severity and performance. You no longer need to import FailureLogSeverity 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(), and expect(). 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

03 Jul 06:49
Compare
Choose a tag to compare

Updated and clarified the documentation based on some helpful feedback.

Version 1.5.2

08 Jun 05:03
Compare
Choose a tag to compare

Added my funding link to the package ❤️

Version 1.5.1

01 Jun 02:15
Compare
Choose a tag to compare

Minified the distribution files so that Micro Test-Runner is 28% smaller when unpacked.

Version 1.5.0

15 May 02:41
Compare
Choose a tag to compare
  • 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

04 May 00:00
Compare
Choose a tag to compare
  • 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

01 May 05:11
Compare
Choose a tag to compare

Include correct build files.

Version 1.3.0

01 May 04:02
Compare
Choose a tag to compare
  • Intellisense should now show MicroTestRunner<'sync'> and 'async' instead of MicroTestRunner<false> and true.
  • A context can now be passed to the candidate function by chaining the .context() method.

Version 1.2.0

30 Apr 06:38
Compare
Choose a tag to compare

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.