في V6 ، لتخطي سيناريو ، استخدمت خطاف قبل كل سيناريو
Before({ tags: '<strong i="6">@ignore</strong>' }, async function () {
return 'skipped';
});
لم يعد هذا الكود نفسه مترجمًا في الإصدار 7 باستخدام الكتابة المطبوعة:
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>'.
ما هي الطريقة الصحيحة لتخطي السيناريو في الإصدار 7؟
شكرا
لقد صادفت نفس المشكلة بالضبط أثناء إضافة دعم Cucumber v7 إلى Serenity / JS .
يبدو لي أنها مشكلة في تعريفات النوع بدلاً من الوظيفة الفعلية ، والتي تعمل بنفس الطريقة تمامًا كما كانت في الإصدار السادس.
charlierudolph / davidjgoss ، هل تمانع في التحقق مما إذا كان تفكيري أدناه صحيحًا؟
في support_code_library_builder/types.ts
هناك التعريفات التالية:
export type TestCaseHookFunctionWithoutParameter = () => void | Promise<void>
export type TestCaseHookFunctionWithParameter = (
arg: ITestCaseHookParameter
) => void | Promise<void>
نظرًا لأن الخيار يسمح للخطاف بإرجاع void
، أو string
من 'skipped'
أو 'pending'
، أو Promise
مع إحدى هذه النتائج ، يمكن أن يبدو التطبيق المحسّن بشكل أو بآخر مثل هذا:
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 - سألقي نظرة على هذا بعد قليل.
التعليق الأكثر فائدة
لقد صادفت نفس المشكلة بالضبط أثناء إضافة دعم Cucumber v7 إلى Serenity / JS .
يبدو لي أنها مشكلة في تعريفات النوع بدلاً من الوظيفة الفعلية ، والتي تعمل بنفس الطريقة تمامًا كما كانت في الإصدار السادس.
charlierudolph / davidjgoss ، هل تمانع في التحقق مما إذا كان تفكيري أدناه صحيحًا؟
في
support_code_library_builder/types.ts
هناك التعريفات التالية:نظرًا لأن الخيار يسمح للخطاف بإرجاع
void
، أوstring
من'skipped'
أو'pending'
، أوPromise
مع إحدى هذه النتائج ، يمكن أن يبدو التطبيق المحسّن بشكل أو بآخر مثل هذا:حتى يتم تقديم هذا التغيير أو تغيير مشابه ، سيكون الحل البديل لهذه المشكلة هو تحديد ربط الاختبار على النحو التالي: