Files
cypress/npm/react/cypress/component/basic/window-spec.js
2020-10-14 02:45:48 -04:00

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')
})