Skip to content

Commit

Permalink
make tap return void (wechaty/wechaty#2223)
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Aug 15, 2021
1 parent b69c2c5 commit 20f0c14
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/tap.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ts-node

import { test } from './tap'

test('test smoke testing', async t => {
t.ok('test is ok')
})

// test.only('test smoke testing', async t => {
// t.ok('test is ok')
// })

test.skip('test smoke testing', async t => {
t.ok('test is ok')
})
18 changes: 14 additions & 4 deletions src/tap.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import tap from 'tap'

type TestOptions = NonNullable<ConstructorParameters<typeof tap.Test>[0]>
type TestClass = InstanceType<typeof tap.Test>

interface TestFunc {
(name: string, cb: (t: TestClass) => Promise<void> | void): void
(name: string, extra: TestOptions, cb: (t: TestClass) => Promise<void> | void): void
}

interface Test {
(...args: Parameters<typeof tap.test>): void
only: (...args: Parameters<typeof tap.only>) => void
skip: (...args: Parameters<typeof tap.skip>) => void
only: TestFunc
skip: TestFunc
todo: TestFunc
}

const test: Test = (...args: Parameters<typeof tap.test>) => {
void tap.test(...args)
}

test.only = tap.only
test.skip = tap.skip
test.only = tap.only as any
test.skip = tap.skip as any
test.todo = tap.todo as any

export {
test,
Expand Down

0 comments on commit 20f0c14

Please sign in to comment.