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

cannot skip a scenario anymore in v7 #1529

Closed
hdorgeval opened this issue Jan 1, 2021 · 3 comments · Fixed by #1542
Closed

cannot skip a scenario anymore in v7 #1529

hdorgeval opened this issue Jan 1, 2021 · 3 comments · Fixed by #1542
Labels
🐛 bug Defect / Bug

Comments

@hdorgeval
Copy link

In V6, to skip a scenario, I used a Before each scenario hook

Before({ tags: '@ignore' }, async function () {
  return 'skipped';
});

This same code does not compile anymore in v7 with typescript:

error TS2769: No overload matches this call.
  Overload 1 of 3, '(tags: string, code: TestCaseHookFunction): void', gave the following error.
    Argument of type '{ tags: string; }' is not assignable to parameter of type 'string'.
  Overload 2 of 3, '(options: IDefineTestCaseHookOptions, code: TestCaseHookFunction): void', gave the following error.
    Argument of type '(this: CustomWorld) => Promise<string>' is not assignable to parameter of type 'TestCaseHookFunction'.
      Type '(this: CustomWorld) => Promise<string>' is not assignable to type 'TestCaseHookFunctionWithoutParameter'.
        Type 'Promise<string>' is not assignable to type 'void | Promise<void>'.
          Type 'Promise<string>' is not assignable to type 'Promise<void>'.

What is the right way to skip a scenario in v7?

Thanks

@jan-molak
Copy link
Member

jan-molak commented Jan 2, 2021

I just came across the exact same issue while adding support for Cucumber v7 to Serenity/JS.

It seems to me that it's a problem with type definitions rather than the actual functionality, which works the exact same way as it used to in v6.

@charlierudolph / @davidjgoss, would you mind checking if my thinking below is correct?

In support_code_library_builder/types.ts there are following definitions:

export type TestCaseHookFunctionWithoutParameter = () => void | Promise<void>
export type TestCaseHookFunctionWithParameter = (
  arg: ITestCaseHookParameter
) => void | Promise<void>

Since Cucumber allows for the hook to return void, a string of 'skipped' or 'pending', or a Promise with one of those results, an improved implementation could look more or less like this:

export type TestCaseHookFunctionResult = 'skipped' | 'pending' | void
export type TestCaseHookFunctionWithoutParameter = () => TestCaseHookFunctionResult | Promise<TestCaseHookFunctionResult>
export type TestCaseHookFunctionWithParameter = (
  arg: ITestCaseHookParameter
) => TestCaseHookFunctionResult | Promise<TestCaseHookFunctionResult>

Until this or similar change is introduced, a workaround for this issue would be specifying the test hook as follows:

import { Before } from '@cucumber/cucumber';

Before({ tags: '@ignore' }, function () {
    return 'skipped' as any;
});

@hdorgeval
Copy link
Author

Hi @jan-molak , thank you very much for your feedback, your workaround works perfectly !

@davidjgoss
Copy link
Contributor

Thanks for the workaround @jan-molak - I'll take a look at this one shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants