cypress-autorecord icon indicating copy to clipboard operation
cypress-autorecord copied to clipboard

Why do arrow functions not work.

Open steven-holloway opened this issue 5 years ago • 2 comments

This is not a good enough. "NOTE: Do not use ES6 arrow functions for your describe or it callback. This will cause the recording function to break." Do you have any idea why?

steven-holloway avatar Dec 17 '19 02:12 steven-holloway

because the code uses this.currentTest. However, this can be fixed by listening for Cypress's test:before:run event and setting a global variable in index.js

let currentTest = ''

Cypress.on('test:before:run', ({ title }) => currentTest = title

Then, all references to this.currentTest.title can simply be replaced with currentTest

cellog avatar Dec 17 '19 15:12 cellog

I had the same question. It's an odd requirement and error also prone. I hope it gets fixed.

dani-mp avatar Nov 25 '21 11:11 dani-mp