cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.04k stars 1.09k forks source link

Data Tables not recognizing last row #1539

Closed squarebraket closed 3 years ago

squarebraket commented 3 years ago

Cucumber-js: 7.0.0 Node: v14.5.0 MacOs: 11.1 (Big Sur)

I created the following feature:

Feature: Frequent Flyer status is calculated based on points
  As a Frequent Flyer member
  I want my status to be upgraded as soon as I earn enough points
  So that I can benefit from my higher status sooner

Scenario Outline:
Given "Joe Jones" is a "<initialStatus>" FrequentFlyer member
And "Joe Jones" has <initialStatusPoints> status points
When he earns <extraPoints> extra status points
Then he should have a status of "<finalStatus>"

Examples: Status points required for each level
  | initialStatus | initialStatusPoints | extraPoints | finalStatus 
  | Bronze        | 0                   | 300         | Silver

and the following "step" in Javascript

// Uses this "THEN" statement: Then he should have a status of "<finalStatus>"
Then('he should have a status of {string}', function (string) {
  assert.equal(string, 'Silver');
});

But I got the following error:

✖ Then he should have a status of "" # features/step-definitions/step-with-table.js:31 AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

  • actual - expected

    • ''
    • 'Silver'

      • expected - actual

        - +Silver

        at CustomWorld. (/Users/pedroplopez/Developer/lopez/bdd/jasminesamples/features/step-definitions/step-with-table.js:34:10)

I had to add yet another column to my table for it to work, like this:

Examples: Status points required for each level
  | initialStatus | initialStatusPoints | extraPoints | finalStatus | theEnd
  | Bronze        | 0                   | 300         | Silver     | end

Does anybody see what could be my mistake? Thanks

davidjgoss commented 3 years ago

@squarebraket I think you need to add the lines on the right hand side of the table for the last column to be recognised. So like:

Feature: Frequent Flyer status is calculated based on points
  As a Frequent Flyer member
  I want my status to be upgraded as soon as I earn enough points
  So that I can benefit from my higher status sooner

Scenario Outline:
Given "Joe Jones" is a "<initialStatus>" FrequentFlyer member
And "Joe Jones" has <initialStatusPoints> status points
When he earns <extraPoints> extra status points
Then he should have a status of "<finalStatus>"

Examples: Status points required for each level
  | initialStatus | initialStatusPoints | extraPoints | finalStatus  |
  | Bronze        | 0                   | 300         | Silver |
squarebraket commented 3 years ago

Thanks, @davidjgoss I missed that in the documentation, I didn't read it carefully.

davidjgoss commented 3 years ago

@squarebraket no problem!