diff --git a/CHANGELOG.md b/CHANGELOG.md index 34e74753b..76cb993f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber. ## [Unreleased] +### Fixed +- Fix return type of step hook function to allow async functions ([#2038](https://github.com/cucumber/cucumber-js/pull/2038)) ## [8.2.0] - 2022-05-05 ### Changed diff --git a/features/support/hooks.ts b/features/support/hooks.ts index ce7a5caf3..66d85c3de 100644 --- a/features/support/hooks.ts +++ b/features/support/hooks.ts @@ -1,11 +1,10 @@ -import { After, Before, formatterHelpers } from '../../' +import { After, Before, formatterHelpers, ITestCaseHookParameter } from '../../' import fs from 'fs' import fsExtra from 'fs-extra' import path from 'path' import tmp from 'tmp' import { doesHaveValue } from '../../src/value_checker' import { World } from './world' -import { ITestCaseHookParameter } from '../../src/support_code_library_builder/types' import { warnUserAboutEnablingDeveloperMode } from './warn_user_about_enabling_developer_mode' const projectPath = path.join(__dirname, '..', '..') diff --git a/src/support_code_library_builder/types.ts b/src/support_code_library_builder/types.ts index 5c03d3f77..a33d2c56c 100644 --- a/src/support_code_library_builder/types.ts +++ b/src/support_code_library_builder/types.ts @@ -35,7 +35,7 @@ export type TestCaseHookFunction = ( export type TestStepHookFunction = ( this: WorldType, arg: ITestStepHookParameter -) => void +) => any | Promise export type TestStepFunction = ( this: WorldType, diff --git a/test-d/hooks.ts b/test-d/hooks.ts index 7b582c2f4..4cefcc22e 100644 --- a/test-d/hooks.ts +++ b/test-d/hooks.ts @@ -17,6 +17,14 @@ After(function () {}) BeforeStep(function () {}) AfterStep(function () {}) +// should allow hook functions to be async +BeforeAll(async function () {}) +AfterAll(async function () {}) +Before(async function () {}) +After(async function () {}) +BeforeStep(async function () {}) +AfterStep(async function () {}) + // should allow typed arguments in hooks Before(function (param: ITestCaseHookParameter) {}) After(function (param: ITestCaseHookParameter) {})