I'm trying to create a component test in cypress. I did the setup and all basics tests are working fine.
Now I tried to mock a function with jest:
import { mount } from '@cypress/react'
const onDissmis = jest.fn()
describe('Tags', () => {
describe('Basic', () => {
mount(<Component onDismiss={onDissmis} />)
})
})
I also get the intellisense from VSCode:

However when I try to run the code I get:
The following error originated from your test code, not from Cypress.
> jest is not defined
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.
Probably the ts config is wrong (so it's just referencing me jest but it's not using jest) Maybe mocha? How can I configure the project that it's correct?
This is my tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"types": [
"cypress"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src",
"craco.config.js",
"**/*.ts"
]
}
I don;t know about using Jest with Cypress (you may just be able to add Jest package to the app).
But Cypress has cy.stub(). Does this work?
import { mount } from '@cypress/react'
const onDissmis = cy.stub()
describe('Tags', () => {
describe('Basic', () => {
mount(<Component onDismiss={onDissmis} />)
})
})