Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Error handling regular expressions in v1.2.0+ #4

Closed
brandonramirez opened this issue Dec 13, 2019 · 1 comment
Closed

Error handling regular expressions in v1.2.0+ #4

brandonramirez opened this issue Dec 13, 2019 · 1 comment
Labels

Comments

@brandonramirez
Copy link

I found a bug in isOnPage and isNotOnPage specifically with how it handles regular expressions.

Last known good working version is 1.1.6: https://github.com/mpetrovich/cypress-scenario-runner/blob/v1.1.6/src/behaviors.js#L65
Bug was introduced in 1.2.0: https://github.com/mpetrovich/cypress-scenario-runner/blob/v1.2.0/src/behaviors.js#L68

Steps to reproduce:

  • Define a page in pages.js or wherever you define your list of pages which uses a regular expression such as: 'a profile': /\/profile\/\d+$/, Note this is not a string holding a regular expression pattern, but is an actual RegEx object.
  • Write a Cypress test using cypress-scenario-runner which asserts "is on " (whatever the key in the pages map is)

Expected behavior: Asserting that the browser is "on" a particular page passes if the page's path matches a supplied regular expression pattern.
Observed behavior: Asserting that the browser is "on" a particular page fails with an exception when the given path is a regular expression. Stack trace below

cypress_runner.js:178266 TypeError: path.startsWith is not a function
    at Context.isOnPage (https://www.brandon-ramirez.tnbsdev.com/__cypress/tests?p=cypress/features/development/profiles/heading.feature-169:41121:13)
    at Context.<anonymous> (https://www.brandon-ramirez.tnbsdev.com/__cypress/tests?p=cypress/features/development/profiles/heading.feature-169:41487:23)
    at Context.resolveAndRunStepDefinition (https://www.brandon-ramirez.tnbsdev.com/__cypress/tests?p=cypress/features/development/profiles/heading.feature-169:40965:9)
    at Context.<anonymous> (https://www.brandon-ramirez.tnbsdev.com/__cypress/tests?p=cypress/features/development/profiles/heading.feature-169:40334:35)
From previous event:
    at Context.thenFn (https://www.brandon-ramirez.tnbsdev.com/__cypress/runner/cypress_runner.js:89201:23)
    at Context.then (https://www.brandon-ramirez.tnbsdev.com/__cypress/runner/cypress_runner.js:89525:21)
    at Context.<anonymous> (https://www.brandon-ramirez.tnbsdev.com/__cypress/runner/cypress_runner.js:100860:21)
    at https://www.brandon-ramirez.tnbsdev.com/__cypress/runner/cypress_runner.js:100381:33
From previous event:
    at runCommand (https://www.brandon-ramirez.tnbsdev.com/__cypress/runner/cypress_runner.js:100363:14)
    at next (https://www.brandon-ramirez.tnbsdev.com/__cypress/runner/cypress_runner.js:100498:14)
    at https://www.brandon-ramirez.tnbsdev.com/__cypress/runner/cypress_runner.js:100521:18

Note: I tried temporarily switching to a string holding a regex pattern and the pattern would never match. Not sure if I did something wrong or if there is a further bug there.

@mpetrovich
Copy link
Owner

Fixed in v2.1.1

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

No branches or pull requests

2 participants