Skip to content

Commit

Permalink
fix return type of step hook function to allow async (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss committed May 14, 2022
1 parent 67b1ce2 commit c3e6b12
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions 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, '..', '..')
Expand Down
2 changes: 1 addition & 1 deletion src/support_code_library_builder/types.ts
Expand Up @@ -35,7 +35,7 @@ export type TestCaseHookFunction<WorldType> = (
export type TestStepHookFunction<WorldType> = (
this: WorldType,
arg: ITestStepHookParameter
) => void
) => any | Promise<any>

export type TestStepFunction<WorldType> = (
this: WorldType,
Expand Down
8 changes: 8 additions & 0 deletions test-d/hooks.ts
Expand Up @@ -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) {})
Expand Down

0 comments on commit c3e6b12

Please sign in to comment.