Skip to content
Discussion options

You must be logged in to vote

https://docs.cypress.io/api/cypress-api/custom-queries#Overwriting-Existing-Queries

Remember that query functions rely on this - when you invoke originalFn, be sure to use .call or .apply.

We should probably call that out in an info or warning box, it's important and easy to miss.

I updated your query a little bit - to use function rather than an arrow function and then originalFn.call(this, ...), and now it seems to be working:

Cypress.Commands.overwriteQuery('get', function (originalFn, selector, options) {
  if ((typeof selector === 'string' || selector instanceof 'string') && selector.startsWith('*')) {
    const formattedSelector = selector.replace('*', '');
    return originalFn.c…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@gugarzon
Comment options

@BlueWinds
Comment options

Answer selected by BlueWinds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants