icy-exabyte-68383
04/27/2022, 7:16 PMadorable-smartphone-87280
04/27/2022, 8:28 PMnutritious-oxygen-11772
04/27/2022, 9:22 PMit('follows a link', () => {
cy.visit('https://github.com/cypress-io/cypress')
cy.get('a[href="https://on.cypress.io"]').click()
cy.origin('https://docs.cypress.io/', () => {
cy.get('h1').invoke('text').should('include', 'Why Cypress?')
})
})
icy-exabyte-68383
04/27/2022, 9:25 PMable-monkey-72947
04/27/2022, 9:40 PMcy
object? I'm writing a Jest test for a custom Cypress command (weird, I know, I'm just rolling with it...) and trying to mock stuff in getting pretty wild. It would be a lot easier if I could do something like this -
import cy from 'somewhere'
jest.createMockFromModule('somewhere')
able-monkey-72947
04/27/2022, 9:41 PMnode_modules
somewhere too, I think that's fine for how esoteric of a thing I'm trying to do...gray-kilobyte-89541
04/27/2022, 9:57 PMthankful-controller-3208
04/28/2022, 8:46 AMfresh-doctor-14925
04/28/2022, 10:50 AMcypress run
or cypress open
. That's tripped me up a few timeswitty-kite-3465
04/28/2022, 1:22 PMonly
and only register the intercepts once but I guess they somehow get registered multiple times? Does anyone know how this could happen and if I can do anything to make sure it doesn't happen?rough-monitor-85122
04/28/2022, 2:12 PMbaseUrl
or register your intercepts after cy.visit() - if you visit a domain that isn't your baseURL, cypress will refresh the page during cy.visit, which results in commands earlier in the test getting executed twice. Three times though, IDK. 🤷♀️witty-kite-3465
04/28/2022, 2:20 PMlittle-france-10142
04/28/2022, 3:49 PMalert
to verify (assert?) that the button works as intended when clicked. However my lead said let's use onSubmit
or onClick
instead. I'm looking over the docs for testing .click()
and maybe I'm just missing something really basic and clear but I cannot seem to find a way to assert that the button has, in fact, been clicked. Any help would be greatly appreciated.able-monkey-72947
04/28/2022, 4:16 PMable-monkey-72947
04/28/2022, 4:17 PMrough-monitor-85122
04/28/2022, 4:19 PMlittle-france-10142
04/28/2022, 4:26 PMonClick?: () => void
as a React prop. I suppose I'm just trying to write a test for that base button. My logic is that I should be able to write something like this
it('renders an active base button', () => {
mount(<Button>Click me</Button>)
cy.get(':button').click().should('return.void')
})
able-monkey-72947
04/28/2022, 4:29 PMlittle-france-10142
04/28/2022, 4:31 PMable-monkey-72947
04/28/2022, 4:33 PMrough-monitor-85122
04/28/2022, 4:37 PMable-monkey-72947
04/28/2022, 4:38 PMlittle-france-10142
04/28/2022, 4:38 PMable-monkey-72947
04/28/2022, 4:42 PMable-monkey-72947
04/28/2022, 4:51 PMplugins/index
file,
on('task', {
doesFileExist(filename) {
if (fs.existsSync(filename)) return true
return null
}
})
I'm trying to write a test for a Command that uses this, I'd like to mock/stub what fs.existSync
returns here. Is that possible?able-monkey-72947
04/28/2022, 5:22 PMsalmon-oxygen-44652
04/29/2022, 10:31 AMsalmon-oxygen-44652
04/29/2022, 10:31 AMgray-kilobyte-89541
04/29/2022, 11:20 AM