File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 3
3
* 2.6.1 _ ???.??.2023_
4
4
* [ update README to work w/ eslint-plugin-markdown] ( https://github.com/iambumblehead/esmock/pull/275 )
5
5
* [ update eslint] ( https://github.com/iambumblehead/esmock/pull/276 ) disallow trailing whitespace
6
+ * [ add typescript example] ( https://github.com/iambumblehead/esmock/pull/278 ) to README
6
7
* 2.6.0 _ Nov.07.2023_
7
8
* [ typings: make MockFunction generic,] ( https://github.com/iambumblehead/esmock/pull/267 ) thanks @uwinkelvos
8
9
* 2.5.9 _ Nov.01.2023_
Original file line number Diff line number Diff line change @@ -90,6 +90,25 @@ test('esmock.strict mocks', async () => {
90
90
})
91
91
```
92
92
93
+ ` esmock ` examples in typescript
94
+ ``` ts
95
+ import test from ' node:test'
96
+ import assert from ' node:assert'
97
+ import esmock from ' esmock'
98
+ import type Rabbit from ' ../rabbit.js'
99
+
100
+ test (' specify the type of export returned' , async () => {
101
+ const rabbit = await esmock <Rabbit >(' ../rabbit.js' , {
102
+ ' ../util.js' : {
103
+ multiply : (numbers : number []): number => (
104
+ numbers .reduce ((acc , n ) => acc *= n , 1 ))
105
+ }
106
+ })
107
+
108
+ assert .equal (rabbit .makebabies (), ' 🐇🐇🐇🐇🐇🐇🐇🐇🐇🐇🐇🐇🐇' )
109
+ })
110
+ ```
111
+
93
112
[ 0 ] : https://www.bumblehead.com " bumblehead "
94
113
[ 1 ] : https://github.com/iambumblehead/esmock/workflows/nodejs-ci/badge.svg " nodejs-ci pipeline "
95
114
[ 2 ] : https://github.com/iambumblehead/esmock " esmock "
You can’t perform that action at this time.
0 commit comments