我正在尝试创建
component test in cypress
。我完成了设置,所有基本测试都很好。
现在我试着用笑话来嘲笑一个函数:
import { mount } from '@cypress/react'
const onDissmis = jest.fn()
describe('Tags', () => {
describe('Basic', () => {
mount(<Component onDismiss={onDissmis} />)
})
})
我还从VSCode获得了智能感知:
然而,当我尝试运行代码时,我会得到:
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.
可能ts的配置是错误的(所以它只是引用了我的笑话,但没有使用笑话)也许是摩卡?如何配置项目使其正确?
这是我的
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"
]
}