@@ -16,21 +16,21 @@ type ItArgs<T> =
1616 ]
1717 | [
1818 name : string ,
19- fn : ( context : T ) => void | Promise < void > ,
19+ fn : ( this : T ) => void | Promise < void > ,
2020 ]
21- | [ fn : ( context : T ) => void | Promise < void > ]
21+ | [ fn : ( this : T ) => void | Promise < void > ]
2222 | [
2323 name : string ,
2424 options : Omit < ItDefinition < T > , "fn" | "name" > ,
25- fn : ( context : T ) => void | Promise < void > ,
25+ fn : ( this : T ) => void | Promise < void > ,
2626 ]
2727 | [
2828 options : Omit < ItDefinition < T > , "fn" > ,
29- fn : ( context : T ) => void | Promise < void > ,
29+ fn : ( this : T ) => void | Promise < void > ,
3030 ]
3131 | [
3232 options : Omit < ItDefinition < T > , "fn" | "name" > ,
33- fn : ( context : T ) => void | Promise < void > ,
33+ fn : ( this : T ) => void | Promise < void > ,
3434 ]
3535 | [
3636 suite : TestSuite < T > ,
@@ -40,27 +40,27 @@ type ItArgs<T> =
4040 | [
4141 suite : TestSuite < T > ,
4242 name : string ,
43- fn : ( context : T ) => void | Promise < void > ,
43+ fn : ( this : T ) => void | Promise < void > ,
4444 ]
4545 | [
4646 suite : TestSuite < T > ,
47- fn : ( context : T ) => void | Promise < void > ,
47+ fn : ( this : T ) => void | Promise < void > ,
4848 ]
4949 | [
5050 suite : TestSuite < T > ,
5151 name : string ,
5252 options : Omit < ItDefinition < T > , "fn" | "name" | "suite" > ,
53- fn : ( context : T ) => void | Promise < void > ,
53+ fn : ( this : T ) => void | Promise < void > ,
5454 ]
5555 | [
5656 suite : TestSuite < T > ,
5757 options : Omit < ItDefinition < T > , "fn" | "suite" > ,
58- fn : ( context : T ) => void | Promise < void > ,
58+ fn : ( this : T ) => void | Promise < void > ,
5959 ]
6060 | [
6161 suite : TestSuite < T > ,
6262 options : Omit < ItDefinition < T > , "fn" | "name" | "suite" > ,
63- fn : ( context : T ) => void | Promise < void > ,
63+ fn : ( this : T ) => void | Promise < void > ,
6464 ] ;
6565
6666/** Generates an ItDefinition from ItArgs. */
@@ -165,9 +165,9 @@ export function it<T>(...args: ItArgs<T>): void {
165165 sanitizeExit,
166166 sanitizeOps,
167167 sanitizeResources,
168- fn : async ( ) => {
168+ async fn ( ) {
169169 if ( ! TestSuiteInternal . running ) TestSuiteInternal . running = true ;
170- await fn ! ( { } as T ) ;
170+ await fn . call ( { } as T ) ;
171171 } ,
172172 } ) ;
173173 }
@@ -191,7 +191,7 @@ it.ignore = function itIgnore<T>(...args: ItArgs<T>): void {
191191
192192function addHook < T > (
193193 name : HookNames ,
194- fn : ( context : T ) => void | Promise < void > ,
194+ fn : ( this : T ) => void | Promise < void > ,
195195) : void {
196196 if ( ! TestSuiteInternal . current ) {
197197 if ( TestSuiteInternal . started ) {
@@ -210,28 +210,28 @@ function addHook<T>(
210210
211211/** Run some shared setup before all of the tests in the suite. */
212212export function beforeAll < T > (
213- fn : ( context : T ) => void | Promise < void > ,
213+ fn : ( this : T ) => void | Promise < void > ,
214214) : void {
215215 addHook ( "beforeAll" , fn ) ;
216216}
217217
218218/** Run some shared teardown after all of the tests in the suite. */
219219export function afterAll < T > (
220- fn : ( context : T ) => void | Promise < void > ,
220+ fn : ( this : T ) => void | Promise < void > ,
221221) : void {
222222 addHook ( "afterAll" , fn ) ;
223223}
224224
225225/** Run some shared setup before each test in the suite. */
226226export function beforeEach < T > (
227- fn : ( context : T ) => void | Promise < void > ,
227+ fn : ( this : T ) => void | Promise < void > ,
228228) : void {
229229 addHook ( "beforeEach" , fn ) ;
230230}
231231
232232/** Run some shared teardown after each test in the suite. */
233233export function afterEach < T > (
234- fn : ( context : T ) => void | Promise < void > ,
234+ fn : ( this : T ) => void | Promise < void > ,
235235) : void {
236236 addHook ( "afterEach" , fn ) ;
237237}
0 commit comments