Cucumber-js: não pode mais pular um cenário na v7

Criado em 1 jan. 2021  ·  3Comentários  ·  Fonte: cucumber/cucumber-js

Na V6, para pular um cenário, usei um gancho Antes de cada cenário

Before({ tags: '<strong i="6">@ignore</strong>' }, async function () {
  return 'skipped';
});

Este mesmo código não é mais compilado na v7 com o texto digitado:

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>'.

Qual é a maneira certa de pular um cenário na v7?

Obrigado

bug since-7

Comentários muito úteis

Acabei de me deparar com o mesmo problema ao adicionar suporte para Cucumber v7 ao Serenity / JS .

Parece-me que é um problema com as definições de tipo em vez da funcionalidade real, que funciona exatamente da mesma maneira que funcionava na v6.

@charlierudolph / @davidjgoss , você se importaria de verificar se meu pensamento abaixo está correto?

Em support_code_library_builder/types.ts existem as seguintes definições:

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

Como o pepino permite que o gancho retorne void , um string de 'skipped' ou 'pending' , ou um Promise com um desses resultados , uma implementação aprimorada poderia ser mais ou menos assim:

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

Até que essa mudança ou outra semelhante seja introduzida, uma solução alternativa para esse problema seria especificar o gancho de teste da seguinte maneira:

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

Before({ tags: '<strong i="25">@ignore</strong>' }, function () {
    return 'skipped' as any;
});

Todos 3 comentários

Acabei de me deparar com o mesmo problema ao adicionar suporte para Cucumber v7 ao Serenity / JS .

Parece-me que é um problema com as definições de tipo em vez da funcionalidade real, que funciona exatamente da mesma maneira que funcionava na v6.

@charlierudolph / @davidjgoss , você se importaria de verificar se meu pensamento abaixo está correto?

Em support_code_library_builder/types.ts existem as seguintes definições:

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

Como o pepino permite que o gancho retorne void , um string de 'skipped' ou 'pending' , ou um Promise com um desses resultados , uma implementação aprimorada poderia ser mais ou menos assim:

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

Até que essa mudança ou outra semelhante seja introduzida, uma solução alternativa para esse problema seria especificar o gancho de teste da seguinte maneira:

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

Before({ tags: '<strong i="25">@ignore</strong>' }, function () {
    return 'skipped' as any;
});

Olá @ jan-molak, muito obrigado por seus comentários, sua solução alternativa funciona perfeitamente!

Obrigado pela solução alternativa @ jan-molak - vou dar uma olhada neste em breve.

Esta página foi útil?
0 / 5 - 0 avaliações

Questões relacionadas

kozhevnikov picture kozhevnikov  ·  6Comentários

lamartire picture lamartire  ·  6Comentários

bmsoko picture bmsoko  ·  7Comentários

NoNameProvided picture NoNameProvided  ·  5Comentários

jfstephe picture jfstephe  ·  4Comentários