A modern, flexible JavaScript test runner for the browser.
ATestRunner is a comprehensive suite for defining, running, and reporting tests which require a DOM environment. It operates on a queue-based system, allowing for asynchronous test execution with flexible output options to the console or a specified DOM element.
Download `ATestRunner.min.js` from the `src` directory and include it in an HTML page.
The default behavior is to log test results to the console.
This is the main function you will use to add your tests to the queue.
info() simply prints some information.
Performs a deep equality comparison between two values. Handles primitives, objects, arrays, Dates, RegExps, Maps, Sets, and circular references.
Returns a promise that resolves after a specified number of milliseconds.
The when() method is a tool for testing asynchronous behaviors where you don't know exactly when a condition will be met. It's especially useful for situations involving animations, network requests, or complex state updates.
Creates a spy on a method of an object. The original method is replaced with a spy that tracks calls and arguments, and then executes the original method.
A generator function that yields all possible combinations of properties from an options object. This is useful for data-driven or combinatorial testing.
Imagine you have a simple Button class that generates a CSS class string based on its properties.
Instead of writing a separate test for every single button variation (primary small, primary medium, primary large, secondary small, etc.), we can use genCombos to generate all these variations for us and run them through a single test template.
Why this is so powerful
Scalability and Maintainability: Imagine you add a new size, 'xlarge'. Instead of writing several new tests, you only need to make one change:
Your test suite instantly and automatically expands from 18 to 24 tests, covering all the new combinations without any extra effort.
Benchmarks a function by running it a specified number of times and measuring the total execution time. Works with both synchronous and asynchronous functions.
When output is set to a CSS selector (or an instance of HTMLElement), the test results are sent to the html element as a series of output elements containing JSON formatted strings.