-
-
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
548 additions
and
36 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,72 @@ | ||
import through = require('@ljharb/through'); | ||
|
||
import Test = require('./lib/test'); | ||
|
||
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; | ||
}; | ||
|
||
declare function createStream(opts?: StreamOptions): ReturnType<through>; | ||
|
||
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 Harness = { | ||
(this: ThisType<Test>, ...args: Parameters<Test>): Test; | ||
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; | ||
exit?: boolean; | ||
} & StreamOptions; | ||
|
||
declare function createHarness(conf_?: HarnessConfig): Harness; | ||
Test = Test; | ||
test = typeof tape; | ||
skip = Test['skip']; | ||
} | ||
|
||
declare function tape(this: tape.Harness, name: string, cb: Test.Callback): Test; | ||
declare function tape(this: tape.Harness, name: string, opts: tape.TestOptions, cb: Test.Callback): Test; | ||
declare function tape(this: tape.Harness, opts?: tape.TestOptions): Test; | ||
declare function tape(this: tape.Harness, opts?: tape.TestOptions, cb: Test.Callback): 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,54 @@ | ||
import through = require('@ljharb/through'); | ||
import type { EventEmitter } from 'events'; | ||
|
||
import type { StreamOptions } from '../'; | ||
import Test = require('./test'); | ||
|
||
type Stream = ReturnType<through>; | ||
|
||
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: Stream; | ||
|
||
close(this: Results): void; | ||
createStream(this: Results, opts?: StreamOptions): Stream; | ||
only(this: Results, t: Test): void; | ||
push(this: Results, t: Test): void; | ||
|
||
_watch(this: Results, t: Test): void; | ||
} | ||
|
||
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.