【发布时间】:2021-10-05 15:26:01
【问题描述】:
我正面临 Cypress 和 Jest 中的类型冲突(例如“expect”)的问题。
example.spec.ts
expect(value).toBe(0) // Property 'toBe' does not exist on type 'Assertion'.
我用下面的方式编辑了tsconfig.json,但是没有解决。
- 从“types”属性中删除“cypress”
- Exclude the jest spec files from in tsconfig.json and declare another tsconfig
- Exclude the jest spec files from in tsconfig.json and add tsconfig in cypress directory
这是我的tsconfig
{
"compilerOptions": {
"target": "ES2018",
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"lib": [
"ESNext",
"ESNext.AsyncIterable",
"DOM"
],
"esModuleInterop": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@nuxt/types",
"@nuxtjs/axios",
"@types/node",
"nuxt-i18n",
"jest"
]
},
"exclude": [
"node_modules",
".nuxt",
"dist"
]
}
【问题讨论】:
标签: typescript jestjs cypress