Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debt: add things to main entry point that people need #1697

Merged
merged 4 commits into from Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a mistake from #1690. The argument isn't optional - we always pass it in - it's just up to the user-authored code whether it does anything with it.

) => 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'
})