背景
我正在从事一个来自angular.js项目的项目。我们目前正在将所有内容迁移到Angular。这意味着我们有Angular.js的旧式单元测试,该测试最终将被删除。对于Angular,我们已将所有测试迁移到Jest。
问题
在项目中同时将Karma and Jasmine
和Jest
都设为问题。旧版单元测试使用其自己的tsconfig文件进行了连接,并且可以正常工作。这两个库似乎都向全局环境添加了相同的功能,并且Jest测试以某种方式不断解析为Jasmine
类型。如果我从项目中删除Karma and Jasmine
,则所有测试都可以正常工作。
问题
在开玩笑时如何排除jasmine's
之类的expect
类型而又不从项目中完全删除karma and jasmine
?
我已经尝试过
我有一个单独的tsconfig.spec
文件用于在jest.config.js
文件中引用的笑话测试。在此,我尝试仅添加所需的类型。我以为只会加载node_modules/@types/<included>
。但它仍将包含茉莉花。
"compilerOptions": {
"types": ["node", "jquery", "jest"],
我也尝试通过typeRoots
包含它们,但这只会给我带来更多错误,例如:error TS2708: Cannot use namespace 'jest' as a value.
。
{
"compilerOptions": {
"outDir": "../out-tsc/spec",
"typeRoots": [
"../node_modules/@types/jest"
...
],
"baseUrl": ".",
"paths": {
"*": ["./*"]
},
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"target": "es5",
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"allowJs": true
},
"files": ["polyfills.ts"],
"include": ["./app/**/*.spec.ts"]
}
我似乎无法使TypeScript忽略node_modules/@types/jasmine
。任何帮助或指针将不胜感激。