【发布时间】:2019-05-11 11:03:37
【问题描述】:
我正在尝试为碰巧导入一个或两个 openlayers 模块的某些模块编写一些测试。但正如其他一些人发现的那样(here、here 和 here),这不是开箱即用的。这是我尝试过的:
- 将
.babelrc重命名为babel.config.js并导出配置 - 已将
transformIgnorePatterns添加到我的jest.config.js
我现在不知道该怎么解决这个问题。
我正在使用:
- 非 CRA webpack 配置
- Jest v23.6.0
- babel-core 6.26.3
- 打字稿 3.1.3
- ts-jest 22.4.6
这是我的配置:
开玩笑:
module.exports = {
setupFiles: [
"./testConfig/test-shim.js",
"./testConfig/test-setup.js"
],
transform: {
"^.+\\.tsx?$": "ts-jest"
},
transformIgnorePatterns: [
"/node_modules/(?!(ol)/).*/",
"node_modules/(?!(ol)/)",
],
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx|tsx?)$",
moduleNameMapper: {
"^(Controllers|Api|Utilities)/(.*)$": "<rootDir>Scripts/$1/$2"
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
coverageReporters: ["text", "text-summary", "html"],
coverageDirectory: "testConfig/coverageReport",
collectCoverageFrom: ["**/Scripts/{App,Controllers,Utilities,Localization,EntryPoints}/**/*.{ts,tsx}"],
coverageThreshold: {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 0
}
}
};
【问题讨论】:
标签: typescript jestjs babeljs openlayers-5