///
// @ts-check
import '../../../src/commands'
describe('should look', () => {
it('checks one element without children or text', () => {
cy.visit('cypress/index.html')
cy.get('#items')
.should('look', '
')
.and('not.look', '')
})
it('checks children elements', () => {
cy.visit('cypress/index.html')
cy.get('#items')
.should('look', '')
.and('not.look', '')
})
it('retries', () => {
cy.visit('cypress/index.html')
cy.get('#items')
// the fifth element appears after a delay
.should('look', '')
})
it('checks the attribute with retries', () => {
cy.visit('cypress/index.html')
// the item appears after a delay
cy.get('#items')
.should(
'look',
'',
)
// without text too
.and('look', '')
})
it('yields the original element', () => {
cy.visit('cypress/index.html')
cy.get('#items')
.should('look', '')
.should('match', 'ul#items')
.invoke('html')
.invoke('trim')
.invoke('split', '\n')
.mapInvoke('trim')
.then((html) => {
expect(html, 'exact html').to.deep.equal([
'first',
'second',
'third',
])
})
})
// TODO: confirm we are checking the elements in order
it.skip('checks attributes', () => {
cy.visit('cypress/index.html')
cy.get('#items').should(
'look',
'',
)
})
it('allows partial class list match', () => {
cy.visit('cypress/e2e/assertions/look.html')
cy.get('#classes')
.should('look', '')
// order does not matter
.and('look', '')
// class "xyz" does not exist
cy.get('#classes').should('not.look', '')
})
// https://github.com/bahmutov/cypress-map/issues/290
it('checks the elements in the given order', () => {
cy.visit('cypress/index.html')
cy.get('#items')
.should(
'look',
`
`,
)
.and(
'look',
`
`,
)
.and(
'look',
`
`,
)
// the fourth child element appear after delay
.and(
'look',
`
`,
)
.and(
'not.look',
// the order of children is wrong
`
`,
)
})
})