💡 What will happen after running the following tests?
beforeEach(() => {
cy.wrap('some text').as('text');
});
it('test #1', () => {
cy.log(this.text);
});
it('test #2', function () {
cy.log(this.text);
});A | Both tests will print 'some text'
B | Both tests will fail
C | First test will print 'some text', second one will fail
D | First test will fail, second one will print 'some text'
🎉 Quiz Completed! 🎉
The
.as() command is used to store the value of the previous command.
You can access the stored value using
this keyword.
However,
this is not available in arrow functions.