mirror of
https://github.com/denoland/deno.git
synced 2025-09-29 13:44:47 +00:00
feat(unstable/test): imperative test steps API (#12190)
This commit is contained in:
parent
668b400ff2
commit
426ebf854a
18 changed files with 1279 additions and 46 deletions
12
cli/dts/lib.deno.ns.d.ts
vendored
12
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -113,8 +113,12 @@ declare namespace Deno {
|
|||
* See: https://no-color.org/ */
|
||||
export const noColor: boolean;
|
||||
|
||||
/** **UNSTABLE**: New option, yet to be vetted. */
|
||||
export interface TestContext {
|
||||
}
|
||||
|
||||
export interface TestDefinition {
|
||||
fn: () => void | Promise<void>;
|
||||
fn: (t: TestContext) => void | Promise<void>;
|
||||
name: string;
|
||||
ignore?: boolean;
|
||||
/** If at least one test has `only` set to true, only run tests that have
|
||||
|
@ -127,7 +131,6 @@ declare namespace Deno {
|
|||
* after the test has exactly the same contents as before the test. Defaults
|
||||
* to true. */
|
||||
sanitizeResources?: boolean;
|
||||
|
||||
/** Ensure the test case does not prematurely cause the process to exit,
|
||||
* for example via a call to `Deno.exit`. Defaults to true. */
|
||||
sanitizeExit?: boolean;
|
||||
|
@ -184,7 +187,10 @@ declare namespace Deno {
|
|||
* });
|
||||
* ```
|
||||
*/
|
||||
export function test(name: string, fn: () => void | Promise<void>): void;
|
||||
export function test(
|
||||
name: string,
|
||||
fn: (t: TestContext) => void | Promise<void>,
|
||||
): void;
|
||||
|
||||
/** Exit the Deno process with optional exit code. If no exit code is supplied
|
||||
* then Deno will exit with return code of 0.
|
||||
|
|
37
cli/dts/lib.deno.unstable.d.ts
vendored
37
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -948,6 +948,43 @@ declare namespace Deno {
|
|||
};
|
||||
}
|
||||
|
||||
/** **UNSTABLE**: New option, yet to be vetted. */
|
||||
export interface TestContext {
|
||||
/** Run a sub step of the parent test with a given name. Returns a promise
|
||||
* that resolves to a boolean signifying if the step completed successfully.
|
||||
* The returned promise never rejects unless the arguments are invalid.
|
||||
* If the test was ignored, the promise returns `false`.
|
||||
*/
|
||||
step(t: TestStepDefinition): Promise<boolean>;
|
||||
|
||||
/** Run a sub step of the parent test with a given name. Returns a promise
|
||||
* that resolves to a boolean signifying if the step completed successfully.
|
||||
* The returned promise never rejects unless the arguments are invalid.
|
||||
* If the test was ignored, the promise returns `false`.
|
||||
*/
|
||||
step(
|
||||
name: string,
|
||||
fn: (t: TestContext) => void | Promise<void>,
|
||||
): Promise<boolean>;
|
||||
}
|
||||
|
||||
/** **UNSTABLE**: New option, yet to be vetted. */
|
||||
export interface TestStepDefinition {
|
||||
fn: (t: TestContext) => void | Promise<void>;
|
||||
name: string;
|
||||
ignore?: boolean;
|
||||
/** Check that the number of async completed ops after the test is the same
|
||||
* as number of dispatched ops. Defaults to true. */
|
||||
sanitizeOps?: boolean;
|
||||
/** Ensure the test case does not "leak" resources - ie. the resource table
|
||||
* after the test has exactly the same contents as before the test. Defaults
|
||||
* to true. */
|
||||
sanitizeResources?: boolean;
|
||||
/** Ensure the test case does not prematurely cause the process to exit,
|
||||
* for example via a call to `Deno.exit`. Defaults to true. */
|
||||
sanitizeExit?: boolean;
|
||||
}
|
||||
|
||||
/** **UNSTABLE**: new API, yet to be vetted.
|
||||
*
|
||||
* A generic transport listener for message-oriented protocols. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue