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

Add ability to change spec text before executing it

Open bahmutov opened this issue 5 years ago • 0 comments

Example: we mount the DOM markup in a div, while some tests might assume they use the full iframe

// By default, root is the document
cy.root().should('match', 'html')
Screen Shot 2020-04-11 at 2 27 56 PM

So this test fails, but would pass if we ran

// By default, root is the document
cy.root().should('match', 'div#live')

It would be nice to give us ability to have hidden text processing over test code before executing it in Cypress

<!-- fiddle -->
```js
// By default, root is the document
cy.root().should('match', 'html')
```
```js transform
code.replace('html', 'div#live')
```

Where we execute js transform block if found by giving it a variable code with the current test code and then we evaluate the returned code.

bahmutov avatar Apr 11 '20 18:04 bahmutov