We have introduced cypress 9.3.1 in our project for e2e test. Now we face the problem that our existing jest test don't compile in the CI.
The following error occures for all parameterized tests:
Property 'each' does not exist on type 'TestFunction'.
it.each<TestCase>([
Question: How to fix it?
What we tried and did't work:
Adding import { it } from '@jest/globals'
to every test. We where able to fix a similar problem (Property 'toBeTruthy' does not exist on type 'Assertion') by adding import { expect } from '@jest/globals'
to every test. See: https://stackoverflow.com/a/65153905
Adding a project wide exclusion for cypress globals, by adding "exclude": ["cypress/global.d.ts"]
to the tsconfig.spec.json
We are using the tsconfig.json as described here (see @JRJurman answer) but that doesn't worked in our project.
Now we are using the cypress-each plugin, developed by one of the cypress contributors.
npm i -D cypress-each
usage:
import 'cypress-each'
// create a separate test for each selector
const selectors = ['header', 'footer', '.new-todo']
it.each(selectors)('element %s is visible', (selector) => {
cy.visit('/')
cy.get(selector).should('be.visible')
})