|
| 1 | +import type { ThroughStream } from '@ljharb/through'; |
| 2 | + |
| 3 | +import type Test from './lib/test'; |
| 4 | +import type Results from './lib/results'; |
| 5 | + |
| 6 | +declare function harnessFunction(this: Test, name: string, opts: tape.TestOptions, cb: Test.TestCase): Test; |
| 7 | +declare function harnessFunction(this: Test, name: string, opts: tape.TestOptions): Test; |
| 8 | +declare function harnessFunction(this: Test, name: string, cb: Test.TestCase): Test; |
| 9 | +declare function harnessFunction(this: Test, name: string): Test; |
| 10 | +declare function harnessFunction(this: Test, opts: tape.TestOptions, cb: Test.TestCase): Test; |
| 11 | +declare function harnessFunction(this: Test, opts: tape.TestOptions): Test; |
| 12 | +declare function harnessFunction(this: Test, cb: Test.TestCase): Test; |
| 13 | + |
| 14 | +declare function harnessFunction(this: void, name: string, opts: tape.TestOptions, cb: Test.TestCase): Test; |
| 15 | +declare function harnessFunction(this: void, name: string, opts: tape.TestOptions): Test; |
| 16 | +declare function harnessFunction(this: void, name: string, cb: Test.TestCase): Test; |
| 17 | +declare function harnessFunction(this: void, name: string): Test; |
| 18 | +declare function harnessFunction(this: void, opts: tape.TestOptions, cb: Test.TestCase): Test; |
| 19 | +declare function harnessFunction(this: void, opts: tape.TestOptions): Test; |
| 20 | +declare function harnessFunction(this: void, cb: Test.TestCase): Test; |
| 21 | + |
| 22 | +declare namespace tape { |
| 23 | + export type TestOptions = { |
| 24 | + objectPrintDepth?: number | undefined; |
| 25 | + skip?: boolean | string | undefined; |
| 26 | + timeout?: number | undefined; |
| 27 | + todo?: boolean | string | undefined; |
| 28 | + }; |
| 29 | + |
| 30 | + export interface AssertOptions { |
| 31 | + skip?: boolean | string | undefined; |
| 32 | + todo?: boolean | string | undefined; |
| 33 | + message?: string | undefined; |
| 34 | + actual?: unknown; |
| 35 | + expected?: unknown; |
| 36 | + exiting?: boolean; |
| 37 | + } |
| 38 | + |
| 39 | + export interface StreamOptions { |
| 40 | + objectMode?: boolean | undefined; |
| 41 | + } |
| 42 | + |
| 43 | + function createStream(opts?: StreamOptions): ThroughStream; |
| 44 | + |
| 45 | + export type CreateStream = typeof createStream; |
| 46 | + |
| 47 | + export type HarnessEventHandler = (cb: Test.SyncCallback, ...rest: unknown[]) => void; |
| 48 | + |
| 49 | + function only(name: string, cb: Test.TestCase): void; |
| 50 | + function only(name: string, opts: tape.TestOptions, cb: Test.TestCase): void; |
| 51 | + function only(cb: Test.TestCase): void; |
| 52 | + function only(opts: tape.TestOptions, cb?: Test.TestCase): void; |
| 53 | + |
| 54 | + export type Harness = typeof harnessFunction & { |
| 55 | + run?: () => void; |
| 56 | + only: typeof only; |
| 57 | + _exitCode: number; |
| 58 | + _results: Results; |
| 59 | + _tests: Test[]; |
| 60 | + close: () => void; |
| 61 | + createStream: CreateStream; |
| 62 | + onFailure: HarnessEventHandler; |
| 63 | + onFinish: HarnessEventHandler; |
| 64 | + } |
| 65 | + |
| 66 | + export type HarnessConfig = { |
| 67 | + autoclose?: boolean; |
| 68 | + noOnly?: boolean; |
| 69 | + stream?: NodeJS.WritableStream | ThroughStream; |
| 70 | + exit?: boolean; |
| 71 | + } & StreamOptions; |
| 72 | + |
| 73 | + function createHarness(conf_?: HarnessConfig): Harness; |
| 74 | + const Test: Test; |
| 75 | + const test: Harness; |
| 76 | + const skip: Test['skip']; |
| 77 | + |
| 78 | + function getHarness(opts?: HarnessConfig): Harness; |
| 79 | + function run(): void; |
| 80 | + function onFailure(cb: Test.SyncCallback, ...rest: unknown[]): void; |
| 81 | + function onFinish(cb: Test.SyncCallback, ...rest: unknown[]): void |
| 82 | + function wait(): void; |
| 83 | +} |
| 84 | + |
| 85 | +declare function tape(this: void | tape.Harness, name: string, opts: tape.TestOptions, cb: Test.TestCase): Test; |
| 86 | +declare function tape(this: void | tape.Harness, name: string, cb: Test.TestCase): Test; |
| 87 | +declare function tape(this: void | tape.Harness, opts?: tape.TestOptions): Test; |
| 88 | +declare function tape(this: void | tape.Harness, opts: tape.TestOptions, cb: Test.TestCase): Test; |
| 89 | +declare function tape(this: void | tape.Harness, cb: Test.TestCase): Test; |
| 90 | +declare function tape(this: void | tape.Harness, name: string): Test; |
| 91 | + |
| 92 | +export = tape; |
0 commit comments