describe('Check Broken links', ()=>{
beforeEach(function() {
cy.visit('https://www.cypress.io/').get('a').as('links')
})
it('prints handler', ()=> {
console.log(this.links);
});
});
package.json
{
"name": "cypress_test",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"cypress:open": "cypress open"
},
"author": "",
"license": "ISC",
"devDependencies": {
"cypress": "^3.4.1"
}
}

it should print the "links" in the console
https://on.cypress.io/variables-and-aliases#Sharing-Context
You can not access mocha context from arrow function, please use es5 function syntax:
it('has access to text', function () {
this.text // is now available
})
@Shelex Thanks for the response. I replaced arrow function with the ES5 syntax and it worked
Most helpful comment
https://on.cypress.io/variables-and-aliases#Sharing-Context
You can not access mocha context from arrow function, please use es5 function syntax: