@japa/runner
Version:
A simple yet powerful testing framework for Node.js
70 lines (69 loc) • 2.42 kB
TypeScript
import { Emitter, Refiner, Test as BaseTest, Suite as BaseSuite, Group as BaseGroup, Runner as BaseRunner, TestContext as BaseTestContext } from '@japa/core';
import { BaseReporter } from './reporters/base.js';
import type { DataSetNode, TestHooksCleanupHandler } from './types.js';
declare module '@japa/core' {
interface Test<Context extends Record<any, any>, TestData extends DataSetNode = undefined> {
/**
* Assert the test throws an exception with a certain error message
* and optionally is an instance of a given Error class.
*/
throws(message: string | RegExp, errorConstructor?: any): this;
}
interface TestContext {
/**
* Register a cleanup function that runs after the test finishes
* successfully or with an error.
*/
cleanup: (cleanupCallback: TestHooksCleanupHandler<TestContext>) => void;
}
}
export { Emitter, Refiner, BaseReporter };
/**
* Test context carries context data for a given test.
*/
export declare class TestContext extends BaseTestContext {
test: Test;
/**
* Register a cleanup function that runs after the test finishes
* successfully or with an error.
*/
cleanup: (cleanupCallback: TestHooksCleanupHandler<TestContext>) => void;
constructor(test: Test);
}
/**
* Test class represents an individual test and exposes API to tweak
* its runtime behavior.
*/
export declare class Test<TestData extends DataSetNode = undefined> extends BaseTest<TestContext, TestData> {
/**
* @inheritdoc
*/
static executedCallbacks: never[];
/**
* @inheritdoc
*/
static executingCallbacks: never[];
/**
* Assert the test throws an exception with a certain error message
* and optionally is an instance of a given Error class.
*/
throws(message: string | RegExp, errorConstructor?: any): this;
}
/**
* TestGroup is used to bulk configure a collection of tests and
* define lifecycle hooks for them
*/
export declare class Group extends BaseGroup<TestContext> {
}
/**
* A suite is a collection of tests created around a given
* testing type. For example: A suite for unit tests, a
* suite for functional tests and so on.
*/
export declare class Suite extends BaseSuite<TestContext> {
}
/**
* Runner class is used to execute the tests
*/
export declare class Runner extends BaseRunner<TestContext> {
}