timjroberts / cucumber-js-tsflow

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

3.3.0 is not running my @before hooks #63

Closed mozrat closed 4 years ago

mozrat commented 4 years ago

Hi - a test suite that hasn't changed recently started failing at the same time 3.3.0 was released

Last successful test run

@with_baoba_user
   Scenario: When I access the Table API with no filter
2020-07-20T04:20:08.706Z [zontally_e2e:0.0.28] info: Creating Baoba user account
2020-07-20T04:20:08.707Z [zontally_e2e:0.0.28] info: TableCleaner.connect: Connecting to MongoDB: mongodb://service-mongo:27017/localhost_auth
2020-07-20T04:20:08.709Z [zontally_e2e:0.0.28] info: MDB.open: Connection attempt 1
2020-07-20T04:20:08.737Z [zontally_e2e:0.0.28] info: MDB.open: Connected to database
2020-07-20T04:20:08.747Z [zontally_e2e:0.0.28] info: TableCleaner.writeRecord: Record inserted: auth_user/6335567359431933998
2020-07-20T04:20:08.748Z [zontally_e2e:0.0.28] info: TableCleaner.close: Closing DB connection
    GivenI am logged into the API as 'baoba.esres' with password 'password'

and now with 3.3.0

@with_baoba_user
  Scenario: When I access the Table API with no filter
    Given I am logged into the API as 'baoba.esres' with password 'password'
    ✖ failed
      AssertionError
          + expected - actual

          -401
          +200

Appreciate your work on this project.

mozrat commented 4 years ago

I pinned my version to 3.2.0 and my test suite passes again.

wudong commented 4 years ago

Hi @mozrat, do u have tag with this before hook ?

mozrat commented 4 years ago

Hi - Yes, I have a tag @with_baoba_user

Feature: Table REST API
  As a developer integrating with the platform
  I want to be able to access data via the Table REST API
  So that I can consume system data in my application

  Scenario: When I access the Table API anonymously
    Given I am an anonymous user
    When I get the form for the 'portal_page' table from the API
    Then I get HTTP response code 401
    And The JSON error code is 'No token found in HTTP header or cookie'

  @with_baoba_user
  Scenario: When I access the Table API with no filter
    Given I am logged into the API as 'baoba.esres' with password 'password'
    When I get the form for the 'portal_page' table from the API
    Then I get HTTP response code 200

and the hook code is

import { binding, before, after } from 'cucumber-tsflow';
import { ConsoleLog as Log, TableCleaner } from 'z_common';
import { Workspace } from '../step-definitions/Workspace';

@binding([Workspace])
class CreateUsersSteps {

  constructor(protected workspace: Workspace) {}

  @before('with_baoba_user')
  public async createBaobaUser(): Promise<void> {
    const doc = {
      'first_name': 'Baoba',
      'last_name': 'Esres',
      'password': '',
      'sys_class_name': 'auth_user',
      'sys_id': '6335567359431933998',
      'username': 'baoba.esres'
    };

    Log.info('Creating Baoba user account');

    await this.workspace.tableCleaner.writeRecord('localhost_auth', 'auth_user', doc);

  }

}

export = CreateUsersSteps;
wudong commented 4 years ago

As per discussions in https://github.com/timjroberts/cucumber-js-tsflow/issues/45 and https://github.com/timjroberts/cucumber-js-tsflow/pull/49,

if your tag name is not prefixed with '@', previously the cucumber-js-tsflow will add a '@' for you.

However this will break some of the tag expression that can be used in cucumber.js. This behaviour has been removed. so in your code, u will now need to use:

@before('@with_baoba_user')

to work with version 3.3.0+

timjroberts commented 4 years ago

That's our fault. Perhaps we should have released this as a major version change rather than a patch.

wudong commented 4 years ago

@timjroberts it was a minor release 3.2.2 -> 3.3.0. Happy to do a major if all felt it is necessary.

timjroberts commented 4 years ago

Ah yeah, sorry @wudong Perhaps it should have been a major release, happy that it wasn't a patch though. Arguably this change is minor, so we'll see what happens when more folks start picking it up.

mikehaas763 commented 4 years ago

I'm not sure how impactful this will continue to be in the future for downstream users as they redeploy and run into the issue. If we think it could be impactful enough, perhaps we should publish a new minor 3.4.0 version that essentially rolls back the change, and then republish the current 3.3.0 as 4.0.0?

wudong commented 4 years ago

looking again at https://semver.org, tends to agree on what @mikehaas763 suggested...

wudong commented 4 years ago

i have made a new release 3.4.0 now, @mozrat let me know if u still have the problem.

mozrat commented 4 years ago

@wudong all good here - thanks so much