Running .should('have.attr', 'target') and then .invoke('removeAttr', 'target') fails.
See original GitHub issueCurrent behavior:
Running .should('have.attr', 'target)
and right after I run .invoke('removeAttr', 'target')
will failed.
Desired behavior:
Should run the check if attribute target exist and I should be able to remove it after.
Test code to reproduce
it.only('has a link to application author', () => {
cy
.get('.my-link')
.should('have.attr', 'target')
.invoke('removeAttr', 'target')
});
Versions
Cypress: “cypress”: "^5.1.0 OS: Ubuntu 20.04.1 LTS Browser: Chrome Version 85.0.4183.102 (Official Build) (64-bit)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
cypress invoke('removeAttr', 'target') not working
Is failing because you have this assertion .should('have.attr', 'target') before this invocation .invoke('removeAttr', 'target') .
Read more >cypress-io/cypress - Gitter
invoke ('removeAttr' , 'target') not working, so can anyone provide me ... but cypress will only run the last module.export file so if...
Read more >invoke
Send specific arguments to the function · Use cy.invoke('removeAttr', 'target') to get around new tab · Arguments are automatically forwarded to the function....
Read more >Cypress invoke command
Now here we have used the invoke-command and used the JQuery function remove attribute to remove target to focus on the new site...
Read more >Cypress INVOKE Review: A Command you MUST KNOW
Learn what is Cypress Invoke and WHEN you should use it.#cypress #testing #javascript⏰Timestamps: 00:00 - Video Introduction02:25 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A few more tested examples for changing the subject in the few assertions is here https://glebbahmutov.com/cypress-examples/commands/assertions.html#subject
Maybe I should add them to the docs @jennifer-shehane
Yeah, add that to the assertions reference (it seems like you’re already mentioning it here). Otherwise, this seems like a bug and can be confusing.
Also, you should update the Typescript types to reflect this. Right now, chaining a
.then()
off of a.should()
expects anHTMLElement
: