-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
606 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ jobs: | |
range: '< 10' | ||
type: minors | ||
command: npm run tests-only | ||
skip-ls-check: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import type { ThroughStream } from '@ljharb/through'; | ||
|
||
import type Test from './lib/test'; | ||
import type Results from './lib/results'; | ||
|
||
declare function harnessFunction(this: ThisType<Test>, name: string, opts: tape.TestOptions, cb: tape.TestCase): Test; | ||
declare function harnessFunction(this: ThisType<Test>, name: string, opts: tape.TestOptions): Test; | ||
declare function harnessFunction(this: ThisType<Test>, name: string, cb: tape.TestCase): Test; | ||
declare function harnessFunction(this: ThisType<Test>, name: string): Test; | ||
declare function harnessFunction(this: ThisType<Test>, opts: tape.TestOptions, cb: tape.TestCase): Test; | ||
declare function harnessFunction(this: ThisType<Test>, opts: tape.TestOptions): Test; | ||
declare function harnessFunction(this: ThisType<Test>, cb: tape.TestCase): Test; | ||
|
||
declare namespace tape { | ||
export type TestOptions = { | ||
objectPrintDepth?: number | undefined; | ||
skip?: boolean | undefined; | ||
timeout?: number | undefined; | ||
todo?: boolean | undefined; | ||
}; | ||
|
||
export interface AssertOptions { | ||
skip?: boolean | string | undefined; | ||
todo?: boolean | string | undefined; | ||
message?: string | undefined; | ||
actual?: unknown; | ||
expected?: unknown; | ||
exiting?: boolean; | ||
} | ||
|
||
export interface TestCase { | ||
(test: Test): void | Promise<void>; | ||
} | ||
|
||
export interface StreamOptions { | ||
objectMode?: boolean | undefined; | ||
} | ||
|
||
function createStream(opts?: StreamOptions): ThroughStream; | ||
|
||
export type CreateStream = typeof createStream; | ||
|
||
export type HarnessEventHandler = (cb: Test.SyncCallback, ...rest: unknown[]) => void; | ||
|
||
function only(name: string, cb: tape.TestCase): void; | ||
function only(name: string, opts: tape.TestOptions, cb: tape.TestCase): void; | ||
function only(cb: tape.TestCase): void; | ||
function only(opts: tape.TestOptions, cb: tape.TestCase): void; | ||
|
||
export type HarnessCallSignatures = typeof harnessFunction; | ||
|
||
export interface Harness extends HarnessCallSignatures { | ||
run?: () => void; | ||
only: typeof only; | ||
_exitCode: number; | ||
_results: Results; | ||
_tests: Test[]; | ||
close: () => void; | ||
createStream: CreateStream; | ||
onFailure: HarnessEventHandler; | ||
onFinish: HarnessEventHandler; | ||
} | ||
|
||
export type HarnessConfig = { | ||
autoclose?: boolean; | ||
noOnly?: boolean; | ||
stream?: NodeJS.WritableStream | ThroughStream; | ||
exit?: boolean; | ||
} & StreamOptions; | ||
|
||
function createHarness(conf_?: HarnessConfig): Harness; | ||
const Test: Test; | ||
const test: typeof tape; | ||
const skip: Test['skip']; | ||
} | ||
|
||
declare function tape(this: tape.Harness, name: string, opts: tape.TestOptions, cb: tape.TestCase): Test; | ||
declare function tape(this: tape.Harness, name: string, cb: tape.TestCase): Test; | ||
declare function tape(this: tape.Harness, opts?: tape.TestOptions): Test; | ||
declare function tape(this: tape.Harness, opts: tape.TestOptions, cb: tape.TestCase): Test; | ||
|
||
export = tape; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { ThroughStream } from "@ljharb/through"; | ||
|
||
declare function defaultStream(): ThroughStream; | ||
|
||
export = defaultStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import through from '@ljharb/through'; | ||
import type { EventEmitter } from 'events'; | ||
|
||
import type { StreamOptions } from '../'; | ||
import Test = require('./test'); | ||
|
||
declare class Results extends EventEmitter { | ||
constructor(options?: { todoIsOK?: boolean }); | ||
|
||
count: number; | ||
fail: number; | ||
pass: number; | ||
tests: Test[]; | ||
todo: number; | ||
todoIsOK: boolean; | ||
closed?: boolean; | ||
|
||
_isRunning: boolean; | ||
_only: Test | null; | ||
_stream: through.ThroughStream; | ||
|
||
close(this: Results): void; | ||
createStream(this: Results, opts?: StreamOptions): through.ThroughStream; | ||
only(this: Results, t: Test): void; | ||
push(this: Results, t: Test): void; | ||
|
||
_watch(this: Results, t: Test): void; | ||
} | ||
|
||
declare namespace Results { | ||
export type Operator = string; | ||
|
||
export type Result = { | ||
id: number; | ||
ok: boolean; | ||
skip: unknown; | ||
todo: unknown; | ||
name?: string; | ||
operator: undefined | Operator; | ||
objectPrintDepth?: number; | ||
actual?: unknown; | ||
expected?: unknown; | ||
error?: unknown; | ||
functionName?: string; | ||
file?: string; | ||
line?: number; | ||
column?: number; | ||
at?: string; | ||
}; | ||
} | ||
|
||
export = Results; |
Oops, something went wrong.