Cucumber-js: v7ではシナリオをスキップできなくなりました

作成日 2021年01月01日  ·  3コメント  ·  ソース: cucumber/cucumber-js

V6では、シナリオをスキップするために、各シナリオの前にフックを使用しました

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

この同じコードは、タイプスクリプトを使用してv7でコンパイルされなくなりました。

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

v7でシナリオをスキップする正しい方法は何ですか?

ありがとう

bug since-7

最も参考になるコメント

Serenity / JSにCucumberv7のサポートを追加しているときに、まったく同じ問題に遭遇しました。

これは、v6で使用されていたのとまったく同じように機能する実際の機能ではなく、型定義の問題であるように思われます。

@charlierudolph / @davidjgoss 、以下の私の考えが正しいかどうかを確認して

support_code_library_builder/types.tsには、次の定義があります。

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

キュウリは、フックを可能にするので、戻りvoidstring'skipped'または'pending' 、またはPromiseこれらの結果のうちの1つと、改善された実装は多かれ少なかれ次のようになります。

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

この変更または同様の変更が導入されるまで、この問題の回避策は、次のようにテストフックを指定することです。

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

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

全てのコメント3件

Serenity / JSにCucumberv7のサポートを追加しているときに、まったく同じ問題に遭遇しました。

これは、v6で使用されていたのとまったく同じように機能する実際の機能ではなく、型定義の問題であるように思われます。

@charlierudolph / @davidjgoss 、以下の私の考えが正しいかどうかを確認して

support_code_library_builder/types.tsには、次の定義があります。

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

キュウリは、フックを可能にするので、戻りvoidstring'skipped'または'pending' 、またはPromiseこれらの結果のうちの1つと、改善された実装は多かれ少なかれ次のようになります。

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

この変更または同様の変更が導入されるまで、この問題の回避策は、次のようにテストフックを指定することです。

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

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

こんにちは@ jan-molak、フィードバックをありがとうございます、あなたの回避策は完璧に機能します!

回避策@ jan-molakをありがとう-これについてはすぐに見ていきます。

このページは役に立ちましたか?
0 / 5 - 0 評価