标签: jstestrunner

如何将Mocha和Jest与TypeScript一起使用而不会发生冲突?

我正在尝试在一个项目中使用类型安装Mocha和Jest。我们使用严格的类型检查,所以我得到与冲突的全局类型有关的错误。

我尝试创建模糊的模块声明,仅在types中定义Mocha tsconfig。我一直在尝试删除Jest的声明-但这会有所帮助。禁用严格的类型检查或库检查不是一种选择。

我希望它能正常工作,但出现下一个错误。

node_modules/@types/jest/index.d.ts(29,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
node_modules/@types/jest/index.d.ts(31,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
node_modules/@types/jest/index.d.ts(32,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.
node_modules/@types/jest/index.d.ts(34,13): error TS2403: Subsequent …
Run Code Online (Sandbox Code Playgroud)

mocha.js typescript jstestrunner jestjs

7
推荐指数
1
解决办法
396
查看次数

标签 统计

jestjs ×1

jstestrunner ×1

mocha.js ×1

typescript ×1