Cannot find alias created in beforeEach hook in custom command #30135
Unanswered
Ixluxi
asked this question in
Questions and Help
Replies: 2 comments
-
I just tried farming the method off to a utilities .ts file and I get the same error...
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm missing the @ symbol. What a noob mistake. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm trying to abstract out a method that increments how many files have been uploaded for a given test.
I couldn't make this work as a task because Cypress can't read
cy.get
inside a task, so I opted to use a custom command.I'm using badeball/cypress-cucumber-preprocessor FYI.
Step definition file:
In the before (each) hook, I'm creating the alias.
Commands.ts:
Then in my test,
commandThatCallsIncrement
is being called - it uploads a file and attempts to increment the filesUploaded alias.I get this error:
AssertionError: Timed out retrying after 4000ms: Expected to find element:
filesUploaded, but never found it.
Please can you advise how I would achieve my goal?
It seems like it should work - the order of events seems to be:
commandThatCallsIncrement
, which callsincrementFileUploadCount
So it looks like the alias should have been created and be available throughout this journey.
I know that aliases are cleared between tests, but I only want it to work like this on a per-test basis and I'm only running one test.
Thank you for any help you can provide.
Beta Was this translation helpful? Give feedback.
All reactions