japa
Version:
Lean test runner for Node.js
101 lines (100 loc) • 2.58 kB
TypeScript
/**
* @module Core
*/
import { ITestOptions, ITestReport, ICallback, IResolver } from '../Contracts';
/**
* Test class is used for running and defining a test. It supports following
* top level config properties.
*
* - skip : Skip the test
* - skipInCI : Skip the test on CI
* - runInCI : Run only in CI
*/
export declare class Test<T extends any[]> {
title: string;
private _resolveFn;
private _callback;
/**
* When the callback for the function is not defined, then we mark
* the test as todo
*/
private _todo;
/**
* Mark failed tests as passed
*/
private _regression;
/**
* Regression message is set when the passes, but it was meant
* to fail
*/
private _regressionMessage;
/**
* The test timeout. It can be overridden at multiple levels
*/
private _timeout;
/**
* How many times, we should retry the function before marking
* it as failed
*/
private _retries;
/**
* The time spent to run the test. This includes the hooks
* time.
*/
private _duration;
/**
* The test error (if any)
*/
private _error;
/**
* Whether or not to skip the test
*/
private _skip;
/**
* Has test been executed
*/
private _completed;
constructor(title: string, _resolveFn: IResolver<T>, _callback: ICallback<T> | undefined, options: ITestOptions);
/**
* Returns a boolean, telling if exception is hard. Hard exceptions
* fails the regression tests too
*/
private get _isHardException();
/**
* Runs test for given number retries
*/
private _runTest;
/**
* The JSON representation of the test. This is emitted
* as an event to show test state.
*/
toJSON(): ITestReport;
/**
* Retry a test for the given number of counts, before marking
* it as failed.
*/
retry(counts: number): this;
/**
* Set explicit timeout for the given test.
*/
timeout(duration: number): this;
/**
* Runs the test. If retries are defined, then the test will be retried for the
* given number of times before marked as failed. When retrying hooks are not
* executed again.
*
* ```js
* // stack
* [before hook 1, before hook 2]
* [test] (2 retries)
* [after hook 1]
*
* + before hook 1
* + before hook 2
* test (original attempt = failed)
* test (1st attempt = passed)
* + after hook 1
* ```
*/
run(): Promise<void>;
}