Skip to content

Commit 2a5d5b0

Browse files
committed
chore(npm): add expectTypeOf plugin
1 parent 6cbe1ee commit 2a5d5b0

5 files changed

Lines changed: 95 additions & 14 deletions

File tree

package-lock.json

Lines changed: 58 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/test",
3-
"version": "5.4.0",
3+
"version": "5.5.0",
44
"description": "The Athenna test runner. Built on top of Japa.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",
@@ -57,6 +57,7 @@
5757
},
5858
"dependencies": {
5959
"@japa/assert": "^4.1.1",
60+
"@japa/expect-type": "^2.0.3",
6061
"@japa/runner": "^3.1.4",
6162
"@types/sinon": "^10.0.20",
6263
"c8": "^10.1.3",

src/helpers/Runner.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
*/
99

1010
import type { Config, PluginFn } from '#src'
11-
import { Importer, run, assert, configure, processCLIArgs } from '#src'
11+
import {
12+
Importer,
13+
run,
14+
assert,
15+
configure,
16+
processCLIArgs,
17+
expectTypeOf
18+
} from '#src'
1219

1320
export class Runner {
1421
public static files: string[] = []
@@ -80,6 +87,17 @@ export class Runner {
8087
return this.addPlugin(assert())
8188
}
8289

90+
/**
91+
* Add the `expectTypeOf()` plugin.
92+
*
93+
* @example ```ts
94+
* Runner.addExpectTypeOfPlugin()
95+
* ```
96+
*/
97+
public static addExpectTypeOfPlugin(): typeof Runner {
98+
return this.addPlugin(expectTypeOf())
99+
}
100+
83101
/**
84102
* Set the global timeout of all tests.
85103
*

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@
99

1010
import { assert, Assert } from '@japa/assert'
1111
import { spec } from '@japa/runner/reporters'
12+
import { expectTypeOf } from '@japa/expect-type'
1213
import { run, test, configure, processCLIArgs } from '@japa/runner'
1314

14-
export { Assert, run, spec, test, assert, configure, processCLIArgs }
15+
export {
16+
Assert,
17+
run,
18+
spec,
19+
test,
20+
assert,
21+
expectTypeOf,
22+
configure,
23+
processCLIArgs
24+
}
1525

1626
export * from '#src/types'
1727

src/mocks/MockBuilder.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class MockBuilder {
471471
* mock.called // false
472472
* ```
473473
*/
474-
public value(value: any) {
474+
public value(value?: any) {
475475
this.stub = this.stub.value(value)
476476

477477
return this
@@ -489,7 +489,7 @@ export class MockBuilder {
489489
* mock.called // false
490490
* ```
491491
*/
492-
public return(value: any) {
492+
public return(value?: any) {
493493
this.stub = this.stub.returns(value)
494494

495495
return this
@@ -507,7 +507,7 @@ export class MockBuilder {
507507
* mock.called // false
508508
* ```
509509
*/
510-
public throw(value: string | Error | Exception): MockBuilder {
510+
public throw(value?: string | Error | Exception): MockBuilder {
511511
this.stub = this.stub.throws(value)
512512

513513
return this
@@ -525,7 +525,7 @@ export class MockBuilder {
525525
* mock.called // false
526526
* ```
527527
*/
528-
public resolve(value: any) {
528+
public resolve(value?: any) {
529529
this.stub = this.stub.resolves(value)
530530

531531
return this
@@ -543,7 +543,7 @@ export class MockBuilder {
543543
* mock.called // false
544544
* ```
545545
*/
546-
public reject<T = any>(value: T): MockBuilder {
546+
public reject<T = any>(value?: T): MockBuilder {
547547
this.stub = this.stub.rejects(value)
548548

549549
return this

0 commit comments

Comments
 (0)