@QATester-j6t

it worked me after i write this : (for overwrite )

in command.js :

//overwriteing contains()
Cypress.Commands.overwriteQuery(
  "contains",
  function (originalFn, subject, filter, text, options = {}) {
    // Handle optional parameters
    if (typeof text === 'object') {
      options = text
      text = filter
      filter = undefined
    }

    // Add matchCase false
    options = {
      ...options,
      matchCase: false,
    }

    // Fix the binding to avoid internal Cypress error
    const boundFn = originalFn.bind(this)

    return boundFn(subject, filter, text, options)
  }
)

and in customcommand.js :

 cy.get('h1').invoke('text').then((text) => {
  expect(text.trim().toLowerCase()).to.eq('apple macbook pro')
})

@jaminDNB

Thx Sir Pavan, I am very grateful for your videos!

@aggyo400

this commands has crushed my cypress app.

@VIKRAMKAMBLE-x9c

now this works
Cypress.Commands.overwriteQuery(
  "contains",
  function (contains, filter, text, userOptions = {}) {

    // This is parameter resolution from Cypress v12.7.0 source
    if (Cypress._.isRegExp(text)) {
      // .contains(filter, text)
      // Do nothing
    } else if (Cypress._.isObject(text)) {
      // .contains(text, userOptions)
      userOptions = text
      text = filter
      filter = ''
    } else if (Cypress._.isUndefined(text)) {
      // .contains(text)
      text = filter
      filter = ''
    }

    userOptions.matchCase = false;

    let contains0 = contains.bind(this)    // this line fixes the error

    return contains0(filter, text, userOptions)
  }
)

@naimtkhalid3159

Thank you so much sir

@Sam-ng1ft

Thank sir! Nice video❤️

@Swas2225

TQ,Sir, nice expansion,please provide Cypress meterial

@drghungroo7956

I am getting this error
Argument of type '(a: string, b: any, c: string) => void' is not assignable to parameter of type 'CommandFn<"name">'.

@nadiakoluzaeva6800

Hello Sir

I am getting errors for overwriting contains() command
CypressError
The following error originated from your test code, not from Cypress.

> Cannot overwrite the contains the query. Queries cannot be overwritten.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error with any specific test.

We dynamically generated a new test to display this failure. Learn more
Hoping for your reply soon!

@SarahOwusu-o5c

@Jaskierify
1 month ago
Unfortunately last two custom commands (overwrite/login app) result in cypress error: Cannot read properties of undefined (reading 'hasPreviouslyLinkedCommand') 
I did exactly the same way as presented in the video.

i am also facing this error could you help me resolve

@surajkamble3538

Sir now cypress shows error for that over write - ut says cannot overwrite the contains query.querries can be overwritten with with 
Cypress.Commands.overwriteQuerry().

@JoolieEm

Unfortunately last two custom commands (overwrite/login app) result in cypress error: Cannot read properties of undefined (reading 'hasPreviouslyLinkedCommand') 
I did exactly the same way as presented in the video.

@vuthiquynhvan4873

Thanks Sir for great video. I am getting issue with over writing command contains even through I wrote the code like you. I got the message following error:

An uncaught error was detected outside of a testfailed
No commands were issued in this test.
CypressError
The following error originated from your test code, not from Cypress.

> Cannot overwite the contains query. Queries cannot be overwritten.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure

Hoping for your reply soon!

@Lee-rp3ey

hi sir while accessing custom commands in main file im getting a type erroe ( TypeError: cy.login is not a function ) can you please help me

@vikrantchaudhari7017

At time 34:41, you have added cy.wait(3000). What is the point of adding static wait when cypress supports autowait and auto synchronisation?

@enawala

I need your help, i writing similar command to get value from textbox by return value but not success, can you help me

@PradnyaDeshpande-bo8iw

Hello Sir

I am getting error for over writing contains() command
CypressError
The following error originated from your test code, not from Cypress.

> Cannot overwite the contains query. Queries cannot be overwritten.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.Learn more

@vishal7824

Got this error while overwriting custom commands "An uncaught error was detected outside of a test"
I made a separate video for upcoming folks.
https://youtu.be/jmLKhZRojQc

@sandhyakveena36

Video is not clear sir