Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple after Hooks are executed in incorrect order on alternate scenarios #743

Closed
vidz2 opened this issue Jan 27, 2017 · 3 comments
Closed
Labels
🐛 bug Defect / Bug

Comments

@vidz2
Copy link

vidz2 commented Jan 27, 2017

Node version: v6.9.4
Cucumberjs: 2.0.0-rc.6

According to the documentation, multiple after hooks are executed in the reverse order that they were defined.
After upgrading to cucumber version 2.0.0x, the after hooks are executed in the correct order on the 1st scenario and on the second scenario the after hooks are executed from top to bottom as they are defined.

Here are the sample files to reproduce the issue:

hooks.js

'use strict';
var {defineSupportCode} = require('cucumber');

defineSupportCode(function({After,Before}){
  After({tags: '@test'},function(scenario){
        console.log('First After Hook');
    });
  After(function(scenario){
        console.log('Second After Hook');
    });
   Before({tags: '@test'},function(scenario){
        console.log('First Before Hook');
    });
  Before(function(scenario){
        console.log('Second Before Hook');
    });
});

TestHooks.feature

@test
Feature: Sample test

  Scenario: Scenario 1
    Given I navigate to the a test site
    When I do something
    Then something happens

  Scenario: Scenario 2
    Given I navigate to the a test site
    When I do something
    Then something happens

  Scenario: Scenario 3
    Given I navigate to the a test site
    When I do something
    Then something happens

node_modules\.bin\cucumber-js.cmd --require features --format pretty -t @test

Result:
Prints the console message in the correct order from Before Hooks for all scenarios.
But the after hooks prints the console messages in different order between scenarios.

@charlierudolph
Copy link
Member

Thanks for the report! Very sorry about that. Appears the bug is related to reverse(). I had thought it returned a new array but it morphs the original. Should have a fix for this soon

@charlierudolph
Copy link
Member

The fix be released sometime tomorrow. Thanks again for the report

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants