Questions tagged [cypress-custom-commands]
111 questions
8
votes
1 answer
Cypress 10 shows "The 'task' event has not been registered in the setupNodeEvents method. You must register it before using cy.task()"
In the cypress.config.js , I'm trying to register tasks / plug in events and set my env configuration exactly as documented on their guide.
However, when trying to use "on" inside setupNodeEvents I'm getting the error in the title about needing to…

K.A.
- 81
- 1
- 3
4
votes
1 answer
Getting an error using Cypress.Commands.overwriteQuery
I am getting this error while overwriting the contains() method.
Cannot read properties of undefined (reading 'hasPreviouslyLinkedCommand') in cypress
Here is the commands.js file:
Cypress.Commands.add("clickOnLinks", (linkText) => {
…

Dhiman
- 55
- 4
4
votes
0 answers
Cypress custom child command Typescript
I am using Typescript for my Cypress tests and I'm trying to add the type definitions to custom commands in order to improve the readability and provide intellisense/autocomplete.
My custom command should only be chained off a multiselect field so…

gabs66
- 61
- 2
4
votes
1 answer
What is the proper way to overwrite the cy.click() command in Cypress?
I'm trying to build an overwrite for cy.click() to add an additional assertion that must be true before an element is clicked. I know I could do this with a custom command, but I'd rather do it by overriding the built in one so that our existing…

Travis
- 43
- 4
3
votes
1 answer
How to clear browser cache within a Cypress test
Background:
Hey all, I have a Cypress test I'm trying to write that should check whether an image URL has been called, after the image itself has been clicked on.
Currently I run the test and it finds the image URL on the first run but when it is…

devDan
- 45
- 1
- 5
3
votes
1 answer
Share Custom Commands in Cypress across different github repo projects
My organization is fairly big, we use node and are looking into potentially using Cypress. We have like 100 different projects and each have their own Github repository, but we like to share functions and methods and import them. So my question is,…

gotime4
- 309
- 1
- 13
2
votes
1 answer
How to log the previous subject in custom commands in Cypress
I want to add logs to my custom commands in Cypress,
for example
Cypress.Commands.add('shouldBeVisible',
{
prevSubject: 'element',
},
(subject) => {
var getText = cy.wrap(subject);
//…

Zain
- 27
- 1
- 8
2
votes
1 answer
Issue with a recursive function in Cypress. Tests slowing down over time
I am working on a diagnostic application which can ask the user quite a large number of questions (100+). I had been using a recursive function to deal with the questions and their answering but i noticed over time the tests would slow down to a…

Rakesh Loi
- 23
- 4
2
votes
1 answer
Cypress 11 Login beforeEach Via Post Issue
I have a login script written in the command file that I use as a beforeEach in each test spec file. This worked in Cypress 9, but I recently upgraded to Cypress 11 and now the session doesn't carry over into the test.
The command runs successfully,…

Ray Gonzales
- 21
- 2
2
votes
1 answer
cy.wrap().its()... doesn't work when the value in .its() contains a period
I am looking to extract a URL parameter from the current URL I'm testing with Cypress. I was able to basically get the answer from this SO post, however, my extracted values are not available to me when I use Cypress's .its() command.
The parameters…

CatsAndCode
- 377
- 9
- 27
2
votes
0 answers
connect ETIMEDOUT when connecting cypress with DB
I am trying to get a token from the Db in a test in cypress but 8 out of 10 times the connection is timed out attaching the error and stack trace below
When I try to send the query via Db Visualizer or when I access data via a test web app which is…

ruffainn
- 83
- 1
- 14
2
votes
3 answers
Setting the content of TinyMCE Editor in Cypress and Typescript
I am building a React Js application using Typescript. I am writing integration tests for my application using Cypress. I am also using Typescript for writing Cypress tests. I am now trying to set the content of the tiny MCE editor in the Cypress…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
2
votes
2 answers
How to implement a command to get a table cell in Cypress?
I want to create a command with this interface:
cy.getTableCell({ column: 'Name', row: 42 }).contains('Douglas Adams')
Where getTableCell would return the table cell (td) corresponding to the 42-th row of the table on the column 'Name'. I came up…

Allan Juan
- 2,048
- 1
- 18
- 42
2
votes
2 answers
Overwriting an existing command with Cypress
I'm trying to overwrite an existing command in Cypress.io. I'm looking to log() a route response's status & the route's url to extend the functionality of the built-in route(). Unfortunately, I get this message The route undefined had a undefined…

Manuel Abascal
- 5,616
- 5
- 35
- 68
1
vote
2 answers
Cypress Issues Integrating Auth0 with cy.origin and cy.session
I am currently facing a persistent issue while testing my application with Cypress, particularly when attempting to handle login through Auth0. To work around cross-origin issues, I followed the documentation and used cy.origin and cy.session, but…

Santi R
- 27
- 6