Пример на веб-сайте в контексте общего доступа:
Код: Выделить всё
describe('parent', () => {
beforeEach(() => {
cy.wrap('one').as('a')
})
context('child', () => {
beforeEach(() => {
cy.wrap('two').as('b')
})
describe('grandchild', () => {
beforeEach(() => {
cy.wrap('three').as('c')
})
it('can access all aliases as properties', function () {
expect(this.a).to.eq('one') // true
expect(this.b).to.eq('two') // true
expect(this.c).to.eq('three') // true
})
})
})
})
Код: Выделить всё
describe('myTests', () => {
beforeEach(() => {
// producing data resulting in a jquery list element
cy.wrap($element).as('element')
})
it('firstTest', function () {
this.element.click()
})
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -a-it-test
Мобильная версия