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

Support for Doc String type #64

Closed
d4niloArantes opened this issue Nov 25, 2021 · 5 comments
Closed

Support for Doc String type #64

d4niloArantes opened this issue Nov 25, 2021 · 5 comments

Comments

@d4niloArantes
Copy link

Hi! I couldn't find any news about this subject. I did find this issue and this PR in the archived repository but no results.

It still returning null when I try something like

Then('a warning tile will display the following message:', async (t, [], docString) => {
    console.log(docString);
});
@Arthy000
Copy link
Owner

Hi @d4niloArantes,
I'll have a look :D

@Arthy000
Copy link
Owner

Hello again!
Looks like it's done, actually:
The first argument of your function is the TestController.
The second argument is the array containing the parameters from your feature.
The third argument is the data table (that's what's null in your example)
The fourth argument is the doc string :D

Given(`Some step name`, async (t: TestController, ...rest) => {
  console.log('output:', rest);
});
output: [ [], null, 'This is my doc string\nIt works' ]

@d4niloArantes
Copy link
Author

Thank you so much @Arthy000. I was using the 4.0.0 version and it only works for 5.0.0 or above.
Could you add this examples in the examples folder please?

#docstring.feature
Feature: Doc string demo feature

  Scenario: Asserting page subtitle
    Given I open TestCafe demo page
    Then I see the following page subtitle
      """
      This webpage is used as a sample in TestCafe tutorials.
      """

# this only works for v5.0.0 or above
// docstring.js
import { Given, Then } from '@cucumber/cucumber';
import { Selector } from 'testcafe';

Given('I open TestCafe demo page', async t => {
    await t
        .navigateTo('https://devexpress.github.io/testcafe/example/');
});

Then('I see the following page subtitle', async (t, [], dtTable, docString) => {
    await t
        .expect(Selector('header > p').textContent).contains(docString);
});

While I was updating my Cucumber and gherkin-testcafe versions, I faced several problems and the versions that worked were:

"dependencies": {
    "@cucumber/cucumber": "^7.3.1",
    "gherkin-testcafe": "^5.0.0",
    "testcafe": "^1.14.2"
  }

@Arthy000
Copy link
Owner

I was planning to add an example, thanks for providing it :)
Regarding the dependencies of your projet, I'd advise to upgrade to the latest version of this package (5.1.0) and upgrade TestCafe itself to match the version required by gherkin-testcafe (>= 1.15.2)

Arthy000 pushed a commit that referenced this issue Jan 7, 2022
shows how to use docstrings, also fixes the custom param example

re #64
Arthy000 added a commit that referenced this issue Jan 7, 2022
shows how to use docstrings, also fixes the custom param example

re #64

Co-authored-by: Arthur Warnier <[email protected]>
Arthy000 added a commit that referenced this issue Feb 15, 2022
shows how to use docstrings, also fixes the custom param example

re #64

Co-authored-by: Arthur Warnier <[email protected]>
@Arthy000
Copy link
Owner

Documentation updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants