mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-22 06:59:30 -06:00
37 lines
815 B
JavaScript
37 lines
815 B
JavaScript
/// <reference types="cypress" />
|
|
import React from 'react'
|
|
import { mount } from '@cypress/react'
|
|
|
|
export class Component extends React.Component {
|
|
constructor (props) {
|
|
super(props)
|
|
console.log(
|
|
'set window.counter to this component in window',
|
|
window.location.pathname,
|
|
)
|
|
|
|
window.component = this
|
|
}
|
|
|
|
render () {
|
|
return <p>component</p>
|
|
}
|
|
}
|
|
|
|
it('has the same window from the component as from test', () => {
|
|
cy.window()
|
|
.its('location')
|
|
.should('have.property', 'pathname')
|
|
.and('not.equal', 'blank')
|
|
|
|
mount(<Component />)
|
|
cy.contains('component')
|
|
cy.window()
|
|
.its('location.pathname')
|
|
// this filename
|
|
.should('match', /window-spec\.js$/)
|
|
|
|
// the window should have property set by the component
|
|
cy.window().should('have.property', 'component')
|
|
})
|