class TestCase
A class that represents a single test case, part of a TestScope.
class TestCase
Description
Test cases are created using calls to test(). The TestCase instance is passed to the function argument when the test itself is run, so it can use its own TestCase methods — for example to capture log output, keep track of counts, or fail early.
Example
describe("My test scope", () => {
test("My test case", (t) => {
// => t is a TestCase instance
t.log("Logging some values", 123);
t.fail(new Error("Whoops!"));
});
});
Instance Members
- name readonlyThe name of this test case.
- scope readonlyThe scope that contains this test case.
- breakOnFail()Sets a flag to stop all other tests once this test case fails.
- getTime()Returns the elapsed time, or the total time if the test has already completed.
- getLogs()Returns all log output as an array.
- getError()Returns the error that occurred during the test run, if any.
- log(…values)Store the provided values as log output for this test case.
- dump(value)Store the provided value as log output with greater detail.
- getCount(name)Returns the current value of a named counter.
- expectCount(name)Returns a new Assertion for the current value of a named counter.
- count(name, inc?)Increment a named counter.
- fail(error?)Fails this test case immediately with the provided error.
- sleep(ms?)Resolves a promise after a specified timeout.
- pollAsync(poll, interval?, timeout?, onTimeout?)Runs a function at the specified interval (in ms).
- tryRun(f)Runs a function (synchronously), expecting it to throw an error.
- tryRunAsync(f)Runs a function asynchronously, expecting it to throw an error.
- expectNavAsync(timeout, pageId, detail?)Waits for the global navigation location to match the given page ID and detail.
- expectOutputAsync(timeout, …select)Waits for output to be rendered (by the test renderer) that matches the provided filters.
- expectMessageDialogAsync(timeout, …match)Waits for an alert or confirm dialog to be rendered (by the test renderer).
- runTestAsync(timeout?)Runs this test case (used by TestScope).