Skip to content

Commit c3e6b12

Browse files
authored
fix return type of step hook function to allow async (#2038)
1 parent 67b1ce2 commit c3e6b12

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber.
99

1010
## [Unreleased]
11+
### Fixed
12+
- Fix return type of step hook function to allow async functions ([#2038](https://github.com/cucumber/cucumber-js/pull/2038))
1113

1214
## [8.2.0] - 2022-05-05
1315
### Changed

features/support/hooks.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { After, Before, formatterHelpers } from '../../'
1+
import { After, Before, formatterHelpers, ITestCaseHookParameter } from '../../'
22
import fs from 'fs'
33
import fsExtra from 'fs-extra'
44
import path from 'path'
55
import tmp from 'tmp'
66
import { doesHaveValue } from '../../src/value_checker'
77
import { World } from './world'
8-
import { ITestCaseHookParameter } from '../../src/support_code_library_builder/types'
98
import { warnUserAboutEnablingDeveloperMode } from './warn_user_about_enabling_developer_mode'
109

1110
const projectPath = path.join(__dirname, '..', '..')

src/support_code_library_builder/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export type TestCaseHookFunction<WorldType> = (
3535
export type TestStepHookFunction<WorldType> = (
3636
this: WorldType,
3737
arg: ITestStepHookParameter
38-
) => void
38+
) => any | Promise<any>
3939

4040
export type TestStepFunction<WorldType> = (
4141
this: WorldType,

test-d/hooks.ts

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ After(function () {})
1717
BeforeStep(function () {})
1818
AfterStep(function () {})
1919

20+
// should allow hook functions to be async
21+
BeforeAll(async function () {})
22+
AfterAll(async function () {})
23+
Before(async function () {})
24+
After(async function () {})
25+
BeforeStep(async function () {})
26+
AfterStep(async function () {})
27+
2028
// should allow typed arguments in hooks
2129
Before(function (param: ITestCaseHookParameter) {})
2230
After(function (param: ITestCaseHookParameter) {})

0 commit comments

Comments
 (0)