Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix brittle types #385

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 27 additions & 30 deletions types/brittle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,40 @@ declare module 'brittle' {
timeout(ms: number): void
comment(message: string): void
end(): void
test(
test: TestFn
}

type TestCallback = (t: TestInstance) => void | Promise<void>

interface TestFn {
// The brittle docs suggest the return value is `Promise<boolean>` but this is not the case.
(
name: string,
options: TestOptions,
callback: (t: TestInstance) => void | Promise<void>
): Promise<boolean>
test(
): Promise<void>
(
name: string,
callback: (t: TestInstance) => void | Promise<void>
): Promise<boolean>
test(name: string, options: TestOptions): TestInstance
test(options: TestOptions): TestInstance
): Promise<void>
(callback: (t: TestInstance) => void | Promise<void>): Promise<void>
(name: string, options: TestOptions): TestInstance
(name: string): TestInstance
(): TestInstance
// The docs suggest the below is possible, but it isn't
// (options: TestOptions): TestInstance
}

type TestCallback = (t: TestInstance) => void | Promise<void>
interface Test extends TestFn {
test: Test
solo: TestFn
skip: TestFn
}

function test(
name: string,
options: TestOptions,
callback: TestCallback
): Promise<boolean>
function test(name: string, callback: TestCallback): Promise<boolean>
function test(name: string, options: TestOptions): TestInstance
function test(options: TestOptions): TestInstance
function solo(
name: string,
options: TestOptions,
callback: TestCallback
): Promise<boolean>
function solo(name: string, callback: TestCallback): Promise<boolean>
function solo(options: TestOptions): TestInstance
function skip(
name: string,
options: TestOptions,
callback: TestCallback
): Promise<boolean>
function skip(name: string, callback: TestCallback): void
function configure(options: TestOptions): void
export const solo: TestFn
export const skip: TestFn
export const test: Test
export function configure(options: TestOptions): void

export { test, solo, skip, configure }
export default test
}
Loading