Skip to content

Commit

Permalink
debt: add things to main entry point that people need (#1697)
Browse files Browse the repository at this point in the history
* ensure hook parameters are exported

* dont need to mark this arg as possibly undefined

* export runtime options

* expose formatter options
  • Loading branch information
davidjgoss committed Jun 14, 2021
1 parent 13956f6 commit 389f65a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/index.ts
Expand Up @@ -6,12 +6,16 @@ import * as messages from '@cucumber/messages'
export { default as Cli } from './cli'
export { parseGherkinMessageStream } from './cli/helpers'
export { default as PickleFilter } from './pickle_filter'
export { default as Runtime } from './runtime'
export {
default as Runtime,
INewRuntimeOptions,
IRuntimeOptions,
} from './runtime'
export { default as supportCodeLibraryBuilder } from './support_code_library_builder'
export { default as DataTable } from './models/data_table'

// Formatters
export { default as Formatter } from './formatter'
export { default as Formatter, IFormatterOptions } from './formatter'
export { default as FormatterBuilder } from './formatter/builder'
export { default as JsonFormatter } from './formatter/json_formatter'
export { default as ProgressFormatter } from './formatter/progress_formatter'
Expand Down Expand Up @@ -43,4 +47,8 @@ export {
IWorld,
IWorldOptions,
} from './support_code_library_builder/world'
export {
ITestCaseHookParameter,
ITestStepHookParameter,
} from './support_code_library_builder/types'
export const Status = messages.TestStepResultStatus
4 changes: 2 additions & 2 deletions src/support_code_library_builder/types.ts
Expand Up @@ -25,12 +25,12 @@ export interface ITestStepHookParameter {

export type TestCaseHookFunction<WorldType> = (
this: WorldType,
arg?: ITestCaseHookParameter
arg: ITestCaseHookParameter
) => any | Promise<any>

export type TestStepHookFunction<WorldType> = (
this: WorldType,
arg?: ITestStepHookParameter
arg: ITestStepHookParameter
) => void

export type TestStepFunction<WorldType> = (
Expand Down
27 changes: 25 additions & 2 deletions test-d/hooks.ts
@@ -1,9 +1,32 @@
import { After, Before } from '../'
import {
After,
AfterAll,
AfterStep,
Before,
BeforeAll,
BeforeStep,
ITestCaseHookParameter,
ITestStepHookParameter,
} from '../'

// should allow argument-less hooks
BeforeAll(function () {})
AfterAll(function () {})
Before(function () {})
After(function () {})
BeforeStep(function () {})
AfterStep(function () {})

// should allow typed arguments in hooks
Before(function (param: ITestCaseHookParameter) {})
After(function (param: ITestCaseHookParameter) {})
BeforeStep(function (param: ITestStepHookParameter) {})
AfterStep(function (param: ITestStepHookParameter) {})

// should allow us to return 'skipped' from a test case hook
Before(async function () {
return 'skipped'
})

After(async function () {
return 'skipped'
})

0 comments on commit 389f65a

Please sign in to comment.