Skip to content

Dev/issue 7735#10772

Merged
christian-bromann merged 10 commits intowebdriverio:mainfrom
hammzj:dev/issue-7735
Jul 22, 2023
Merged

Dev/issue 7735#10772
christian-bromann merged 10 commits intowebdriverio:mainfrom
hammzj:dev/issue-7735

Conversation

@hammzj
Copy link
Contributor

@hammzj hammzj commented Jul 21, 2023

Proposed changes

Fix for Issue 7735

Updated getPickleIds to allow setting line numbers on Cucumber features. This method would pass in the absolute URI of the feature into the pickleFilter.matches method; the matches method expects a relative URI, so it will skip checking for line numbers if an absolute URI is passed in.

I did not add any new tests for it as there are relatively little within the cucumberEventListener.test.ts file. However, I provided my validations on the Cucumber feature example below:

Normal test
$ npm run test:cucumber

> test:cucumber
> ../../packages/wdio-cli/bin/wdio.js ./cucumber/wdio.conf.js


Execution of 1 workers started at 2023-07-21T17:32:20.451Z

[0-0] RUNNING in chrome - /cucumber/features/my-feature.feature
[0-0] PASSED in chrome - /cucumber/features/my-feature.feature

 "spec" Reporter:
------------------------------------------------------------------
[Chrome 115.0.0.0 darwin #0-0] Running: Chrome (v115.0.0.0) on darwin
[Chrome 115.0.0.0 darwin #0-0] Session ID: 80c074fb-4015-4209-90b5-58ce8c0a02cd
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] » /cucumber/features/my-feature.feature
[Chrome 115.0.0.0 darwin #0-0] Example feature
[Chrome 115.0.0.0 darwin #0-0] As a user of WebdriverIO
[Chrome 115.0.0.0 darwin #0-0] I should be able to use different commands
[Chrome 115.0.0.0 darwin #0-0] to get informations about elements on the page
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Get size of an element
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "https://github.com/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then should the element ".header-logged-out a" be 32px wide and 34.5px high
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Get title of website
[Chrome 115.0.0.0 darwin #0-0] Business rule 1
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "https://github.com/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then should the title of the page be "GitHub: Let’s build from here · GitHub"
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Data Tables
[Chrome 115.0.0.0 darwin #0-0] Business rule 2
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "http://todomvc.com/examples/react/#/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ When I add the following groceries
[Chrome 115.0.0.0 darwin #0-0]      │ Item       │ Amount │
[Chrome 115.0.0.0 darwin #0-0]      │ Milk       │ 2      │
[Chrome 115.0.0.0 darwin #0-0]      │ Butter     │ 1      │
[Chrome 115.0.0.0 darwin #0-0]      │ Noodles    │ 1      │
[Chrome 115.0.0.0 darwin #0-0]      │ Schocolate │ 3      │
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then I should have a list of 4 items
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] 7 passing (4.1s)


Spec Files:      1 passed, 1 total (100% completed) in 00:00:11 
Test with `--spec` option
$ npm run test:cucumber -- --spec ./cucumber/features/my-feature.feature

> test:cucumber
> ../../packages/wdio-cli/bin/wdio.js ./cucumber/wdio.conf.js --spec ./cucumber/features/my-feature.feature


Execution of 1 workers started at 2023-07-21T17:34:18.530Z

[0-0] RUNNING in chrome - /cucumber/features/my-feature.feature
[0-0] PASSED in chrome - /cucumber/features/my-feature.feature

 "spec" Reporter:
------------------------------------------------------------------
[Chrome 115.0.0.0 darwin #0-0] Running: Chrome (v115.0.0.0) on darwin
[Chrome 115.0.0.0 darwin #0-0] Session ID: 4ba0b68e-4e28-4de7-bbd1-00d3993eba2b
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] » /cucumber/features/my-feature.feature
[Chrome 115.0.0.0 darwin #0-0] Example feature
[Chrome 115.0.0.0 darwin #0-0] As a user of WebdriverIO
[Chrome 115.0.0.0 darwin #0-0] I should be able to use different commands
[Chrome 115.0.0.0 darwin #0-0] to get informations about elements on the page
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Get size of an element
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "https://github.com/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then should the element ".header-logged-out a" be 32px wide and 34.5px high
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Get title of website
[Chrome 115.0.0.0 darwin #0-0] Business rule 1
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "https://github.com/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then should the title of the page be "GitHub: Let’s build from here · GitHub"
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Data Tables
[Chrome 115.0.0.0 darwin #0-0] Business rule 2
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "http://todomvc.com/examples/react/#/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ When I add the following groceries
[Chrome 115.0.0.0 darwin #0-0]      │ Item       │ Amount │
[Chrome 115.0.0.0 darwin #0-0]      │ Milk       │ 2      │
[Chrome 115.0.0.0 darwin #0-0]      │ Butter     │ 1      │
[Chrome 115.0.0.0 darwin #0-0]      │ Noodles    │ 1      │
[Chrome 115.0.0.0 darwin #0-0]      │ Schocolate │ 3      │
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then I should have a list of 4 items
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] 7 passing (3.7s)


Spec Files:      1 passed, 1 total (100% completed) in 00:00:09 

Test with single line number
$ npm run test:cucumber -- --spec ./cucumber/features/my-feature.feature:11

> test:cucumber
> ../../packages/wdio-cli/bin/wdio.js ./cucumber/wdio.conf.js --spec ./cucumber/features/my-feature.feature:11


Execution of 1 workers started at 2023-07-21T17:33:16.147Z

[0-0] RUNNING in chrome - /cucumber/features/my-feature.feature
[0-0] PASSED in chrome - /cucumber/features/my-feature.feature

 "spec" Reporter:
------------------------------------------------------------------
[Chrome 115.0.0.0 darwin #0-0] Running: Chrome (v115.0.0.0) on darwin
[Chrome 115.0.0.0 darwin #0-0] Session ID: 01952991-33c2-4094-a80b-ffdcce7305d6
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] » /cucumber/features/my-feature.feature
[Chrome 115.0.0.0 darwin #0-0] Example feature
[Chrome 115.0.0.0 darwin #0-0] As a user of WebdriverIO
[Chrome 115.0.0.0 darwin #0-0] I should be able to use different commands
[Chrome 115.0.0.0 darwin #0-0] to get informations about elements on the page
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Get title of website
[Chrome 115.0.0.0 darwin #0-0] Business rule 1
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "https://github.com/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then should the title of the page be "GitHub: Let’s build from here · GitHub"
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] 2 passing (1.9s)


Spec Files:      1 passed, 1 total (100% completed) in 00:00:08 
Test with `--spec` and multiple line numbers
$ npm run test:cucumber -- --spec ./cucumber/features/my-feature.feature:11:16

> test:cucumber
> ../../packages/wdio-cli/bin/wdio.js ./cucumber/wdio.conf.js --spec ./cucumber/features/my-feature.feature:11:16


Execution of 1 workers started at 2023-07-21T17:36:15.811Z

[0-0] RUNNING in chrome - /cucumber/features/my-feature.feature
[0-0] PASSED in chrome - /cucumber/features/my-feature.feature

 "spec" Reporter:
------------------------------------------------------------------
[Chrome 115.0.0.0 darwin #0-0] Running: Chrome (v115.0.0.0) on darwin
[Chrome 115.0.0.0 darwin #0-0] Session ID: 23d9ca30-07ec-437e-8131-9f97a79bf543
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] » /cucumber/features/my-feature.feature
[Chrome 115.0.0.0 darwin #0-0] Example feature
[Chrome 115.0.0.0 darwin #0-0] As a user of WebdriverIO
[Chrome 115.0.0.0 darwin #0-0] I should be able to use different commands
[Chrome 115.0.0.0 darwin #0-0] to get informations about elements on the page
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Get title of website
[Chrome 115.0.0.0 darwin #0-0] Business rule 1
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "https://github.com/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then should the title of the page be "GitHub: Let’s build from here · GitHub"
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] Data Tables
[Chrome 115.0.0.0 darwin #0-0] Business rule 2
[Chrome 115.0.0.0 darwin #0-0]    ✓ Given I go on the website "http://todomvc.com/examples/react/#/"
[Chrome 115.0.0.0 darwin #0-0]    ✓ When I add the following groceries
[Chrome 115.0.0.0 darwin #0-0]      │ Item       │ Amount │
[Chrome 115.0.0.0 darwin #0-0]      │ Milk       │ 2      │
[Chrome 115.0.0.0 darwin #0-0]      │ Butter     │ 1      │
[Chrome 115.0.0.0 darwin #0-0]      │ Noodles    │ 1      │
[Chrome 115.0.0.0 darwin #0-0]      │ Schocolate │ 3      │
[Chrome 115.0.0.0 darwin #0-0]    ✓ Then I should have a list of 4 items
[Chrome 115.0.0.0 darwin #0-0]
[Chrome 115.0.0.0 darwin #0-0] 5 passing (3s)


Spec Files:      1 passed, 1 total (100% completed) in 00:00:08 

The only issue I faced is that I could not run more than two scenarios at a time this way:

# Does not work!
$ npm run test:cucumber -- --spec ./cucumber/features/my-feature.feature:6:11:16

This StackOverflow answer said it should be possible, but this might be a Cucumber-js issue and not a WDIO issue.


Small updates to Cucumber tests

GitHub's website changed, so I updated the my-feature.feature test document. These test are incredibly flaky since they rely on an third-party website to validate. It would make more sense to validate against a WebDriverIO test website or homepage where the maintainers know what changes are made to their website.

As well, these steps should move away from regular expressions in favor of Cucumber Expressions. See here.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising a PR and investigating the issue. I added some comments.
I wonder if it makes sense to add a smoke test for this to make sure it works.

hammzj and others added 4 commits July 21, 2023 13:52
Co-authored-by: Christian Bromann <git@bromann.dev>
Co-authored-by: Christian Bromann <git@bromann.dev>
Co-authored-by: Christian Bromann <git@bromann.dev>
Co-authored-by: Christian Bromann <git@bromann.dev>
@hammzj
Copy link
Contributor Author

hammzj commented Jul 21, 2023

I'll look at adding smoke tests next week. It's Friday, i gotta hit the gym and then start a weekend-long happy hour

@hammzj hammzj requested a review from christian-bromann July 22, 2023 14:17
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changeset .. awesome job 👍
Have a great weekend!

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Jul 22, 2023
@christian-bromann christian-bromann merged commit b8f4811 into webdriverio:main Jul 22, 2023
@hammzj hammzj deleted the dev/issue-7735 branch July 22, 2023 18:07
hammzj pushed a commit to hammzj/webdriverio that referenced this pull request Jul 24, 2023
@hammzj hammzj mentioned this pull request Jul 24, 2023
8 tasks
christian-bromann pushed a commit that referenced this pull request Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants