timjroberts / cucumber-js-tsflow

Provides 'specflow' like bindings for Cucumber.js in TypeScript 1.7+.
MIT License
133 stars 34 forks source link

Async syntax does not work #39

Closed bkostrowiecki closed 4 years ago

bkostrowiecki commented 5 years ago

I'm afraid that async syntax does not work properly:

Minimal test case:

# async-test.feature
Feature: Test async function

Scenario: Test async function
    Then Test async function
# async-test.steps.ts
import { binding, given, then, when} from 'cucumber-tsflow';

@binding()
export class AsyncFunctionSteps {
  @given(/Test async function/)
  public async givenAnAccountWithStartingBalance(amount: string) {
    await this.test();
  }

  private async test() {
    return new Promise((resolve) => resolve());
  }
}

The results:

Failures:

1) Scenario: Test async function # features\async-test.feature:3
   √ Before # node_modules\cucumber-tsflow\src\binding-decorator.ts:78
   × Then Test async function # node_modules\cucumber-tsflow\src\binding-decorator.ts:176
       Error: function uses multiple asynchronous interfaces: callback and promise
       to use the callback interface: do not return a promise
       to use the promise interface: remove the last argument to the function
           at F:\cucumber-watch\node_modules\cucumber\lib\user_code_runner.js:56:18
           at Generator.next (<anonymous>)
           at asyncGeneratorStep (F:\cucumber-watch\node_modules\cucumber\lib\user_code_runner.js:18:103)
           at _next (F:\cucumber-watch\node_modules\cucumber\lib\user_code_runner.js:20:194)
           at F:\cucumber-watch\node_modules\cucumber\lib\user_code_runner.js:20:364
           at new Promise (<anonymous>)
           at F:\cucumber-watch\node_modules\cucumber\lib\user_code_runner.js:20:97
           at Function.run (F:\cucumber-watch\node_modules\cucumber\lib\user_code_runner.js:109:7)
           at Object.<anonymous> (F:\cucumber-watch\node_modules\cucumber\lib\runtime\step_runner.js:59:54)
           at Generator.next (<anonymous>)
           at asyncGeneratorStep (F:\cucumber-watch\node_modules\cucumber\lib\runtime\step_runner.js:20:103)
           at _next (F:\cucumber-watch\node_modules\cucumber\lib\runtime\step_runner.js:22:194)
   √ After # node_modules\cucumber-tsflow\src\binding-decorator.ts:85
bkostrowiecki commented 5 years ago

I'm sorry, you can close this.

This is just misleading message when you declared more arguments in the function than you declared in the step decorator descriptor.