cypress-testing-library: Cypress commands don't work inside an origin block
cypress-testing-libraryversion: 7.0.6nodeversion: 14.17.5npm(oryarn) version: 6.14.15- Cypress 9.6.1 (9.6.0 min needed for experimental cy.origin function)
Relevant code or config
"experimentalSessionAndOrigin": true,
cy.visit('/')
// works as expected
cy.findByText('foo')
cy.origin('google.com', () => {
cy.visit('/')
// will crash with "cy.findByText is not a function"
cy.findByText('foo')
})
What you did:
- called
cy.findByTextwithin acy.origincallback
What happened:
- crashed with “cy.findByText is not a function” error

About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 12
- Comments: 19 (1 by maintainers)
This is a known limitation with cy.origin (that custom commands don’t work). There is a workaround I was pointed to by Gleb which is to make another cy.origin block in the beforeEach block. This origin block would be pointed to the same origin that you are trying to use in your main test. You would setup your custom command in this first origin block and you will be able to use it within the origin block in your test. https://docs.cypress.io/api/commands/origin#Callback-restrictions
@XavierChevalier see https://github.com/cypress-io/cypress/issues/25885 should be fixed with next cypress release (in 4 days)
I have the same problem with cypress-testing-library and real-events
Indeed. Same problem here with
cv.findByRole()etc