Add jest-cucumber-fusion (#43487)

* Add jest-cucumber-fusion

* Add 'declare module'

* Add support for Gherkin tables

* Fix failing tests for jest-cucumber-fusion

- Set minimum ts version

- Fix linting errors
This commit is contained in:
Pelle Johnsen 2020-04-01 21:45:48 +02:00 committed by GitHub
parent bcdbb10669
commit 93d70f87d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 0 deletions

20
types/jest-cucumber-fusion/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
// Type definitions for jest-cucumber-fusion 0.6
// Project: https://github.com/b-yond-infinite-network/jest-cucumber-fusion#readme
// Definitions by: Pelle Johnsen <https://github.com/pjoe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.4
import { loadFeature } from 'jest-cucumber';
export type CallBack = (...args: ReadonlyArray<string | Array<Record<string, string>>>) => void | Promise<void>;
export function Given(name: string | RegExp, callback: CallBack): void;
export function When(name: string | RegExp, callback: CallBack): void;
export function Then(name: string | RegExp, callback: CallBack): void;
export function And(name: string | RegExp, callback: CallBack): void;
export function But(name: string | RegExp, callback: CallBack): void;
export function Before(callback: () => void | Promise<void>): void;
export function After(callback: () => void | Promise<void>): void;
export function Fusion(feature: string, options?: Parameters<typeof loadFeature>[1]): void;

View File

@ -0,0 +1,32 @@
import * as jcf from 'jest-cucumber-fusion';
type CbArgs = ReadonlyArray<string | Array<Record<string, string>>>;
function cb(...args: CbArgs): void {}
async function cbAsync(...args: CbArgs): Promise<void> {}
jcf.Given('', cb); // $ExpectType void
jcf.Given('', cbAsync); // $ExpectType void
jcf.When('', cb); // $ExpectType void
jcf.When('', cbAsync); // $ExpectType void
jcf.Then('', cb); // $ExpectType void
jcf.Then('', cbAsync); // $ExpectType void
jcf.And('', cb); // $ExpectType void
jcf.And('', cbAsync); // $ExpectType void
jcf.But('', cb); // $ExpectType void
jcf.But('', cbAsync); // $ExpectType void
jcf.After(() => {}); // $ExpectType void
jcf.After(async () => {}); // $ExpectType void
jcf.Before(() => {}); // $ExpectType void
jcf.Before(async () => {}); // $ExpectType void
jcf.Fusion(''); // $ExpectType void
jcf.Fusion('', { errors: true }); // $ExpectType void
jcf.Fusion('', { loadRelativePath: true }); // $ExpectType void
jcf.Fusion('', { scenarioNameTemplate: vars => vars.featureTitle }); // $ExpectType void
jcf.Fusion('', { tagFilter: '' }); // $ExpectType void

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"jest-cucumber": "^2.0.11"
}
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jest-cucumber-fusion-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }