Questions tagged [cypress-custom-commands]

111 questions
1
vote
1 answer

Code works as a regular function, but not as a Cypress command

I created a function that is supposed to click a dropdown to open it and then check if the options I passed are there. It goes like this: function dropdown(placeholderText: string) { function contains(...values: string[]) { …
Allan Juan
  • 2,048
  • 1
  • 18
  • 42
1
vote
2 answers

How to override the subject option command in Cypress

Cypress says options is only supported for use in Cypress.Commands.add() and not supported for use in Cypress.Commands.overwrite() So we can't change the subject behavior when overwriting a command, and We can't add a new command with the same…
Alexander Leyva Caro
  • 1,183
  • 1
  • 12
  • 21
1
vote
3 answers

How to return string value with .wrap and cypress command feature

I have a code : Cypress.Commands.add('getLabelText', (parentSelector: string, label: string) => { var result: string= ''; cy.get(parentSelector).within(() => { cy.get(`[aria-label="${label}"]`).then(el => { result.replace(el.text(),…
1
vote
1 answer

how can i test different prices for one article from GA4 event with Cypress end2end testing

I'm trying to test if the correct data is being tracked by GA4. However, I have the problem that an article can have several prices depending on whether it is played on the integration environment or on the production environment. The…
1
vote
1 answer

Issues with setting up cypress custom command npm module

Appologies for the huge photos, I dont know how to make them smaller. I guess I'll dive straight in to my issue. I have the following folder structure: I am trying to create a repo of custom cypress commands. I have run into 2 issues. Firstly if…
1
vote
2 answers

Cy.request() times out for no apparent reason

I am currently testing an application using cypress. This application has a back-end(API) and a front-end. Cypress is used to test the front-end. Before beginning a test, we initialize the DB of the back-end to have it in the state needed for the…
Tom
  • 1,357
  • 2
  • 13
  • 32
0
votes
2 answers

How to fix this?
...

below is the response error from running cypress. Timed out retrying after 4000ms: cy.type() failed because this element:
Zack
  • 1
0
votes
0 answers

Cypress smoke test is failing with cypress version 10

I have cypress smoke test which is working fine with cypress version 8.7.0 but failing with version 10. Sample test looks like { describe("Smoke - test login flow", () => { const userId = Cypress.env("test_user"); const customPassword =…
0
votes
1 answer

Cypress (12.16) how do look for a particular ID and if it isn't found then move on to an alternate?

Pretty new to cypress (12.16) here and have a question: I have a form that gets used in multiple areas of the app, I’m trying to turn filling it out into a command to centralize it in case we need to change variables, the issue is that I need to…
0
votes
1 answer

Custom command and 'extra data' that ends up as undefined

I'm trying to overwrite the Cypress within method such that there's an extra argument for the callback. Ultimately, my goal is to be able to go cy.customCommandThatSetsAValue().within((subject, extra) => {}) The issue seems to be a matter of…
user3534080
  • 1,201
  • 1
  • 14
  • 21
0
votes
0 answers

Difference between commands.ts and index.d.ts

When researching custom commands for TypeScript, I see some articles talking about defining these in commands.ts and others recommending creating custom commands in index.d.ts. What is the difference between these two files? I haven't tried this…
0
votes
1 answer

Cypress version 12.14.0 just cannot find command files with Typescript

I am attempting to include custom commands in my Cypress tests using typescript. It just seems so difficult to get it to work. I have moved the files in various folders but it is simply a frustrating experience. It shouldn't be this hard. Here is…
BreenDeen
  • 623
  • 1
  • 13
  • 42
0
votes
2 answers

In Cypress, how do I interact with a newly added element to the page?

I want to use MutationObserver with Cypress because it feels like an appropriate mechanism to use for detecting specific changes occurred to the DOM and then interact with element(s) that were added. Assume that I have a UI that has 3 buttons and a…
Lester Peabody
  • 1,868
  • 3
  • 20
  • 42
0
votes
0 answers

Cypress custom commands

If you have separate repositories for library and consumer, the custom commands defined in one repository(library) is not available in consumer repository. I get cy.samplecommmand() is not a function error Is there a way to use custom commands from…
0
votes
1 answer

Need to run a function with parameter, getting TypeError

I am following POM model in cypress where I have a use case to tick checkboxes in page from json file. My files are as below: homePageTest.cy.js it("some test", () => { cy.fixture("jsonValues").then((data) => { …