cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.

Home Page:https://cypress.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue in Overwrite Customized command

Amara292 opened this issue · comments

Current behavior

Cypress.Commands.overwrite('contains', (originalFn, subject, filter:any,text:any,options={}) => {
    
    //dertermine if filter argument was passed
    if(typeof text==='object'){

        options = text
        text = filter
        filter=undefined
    
    }
    options.matchCase=false
return originalFn(subject,filter,text,options)
})

Desired behavior

Options also should accept as Arguments but getting
below Error

//Iam Unable to take options Argumant
(parameter) options: Parameters<Cypress.ChainableMethods[T]>[3]
Expected 2-3 arguments, but got 4.

Test code to reproduce

describe('Custom Commands', () => {
    it('handling Links', () => {
        cy.visit('https://demo.nopcommerce.com/');
        //cy.get(':nth-child(2) > .product-item > .details > .product-title > a').click()   
        //cy.get('h1').should('have.text','Apple MacBook Pro 13-inch')

       // Using Customcommand
       cy.clickLink('APPLE MACBOOK PROS 13-inch')
       cy.get('h1').should('have.text','Apple MacBook Pro 13-inch')
    })
})

Cypress Version

"12.2.0",

Node version

16.16.0

Operating System

windows

Debug Logs

no

Other

no

I see you are overwriting contains but I do not see a cy.contains usage. Can you post a usage of the overwritten command, or better yet provide a simple reproduction? Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.