【发布时间】:2020-09-05 06:14:46
【问题描述】:
我目前正在对我的项目实施开玩笑测试。该项目由 ts + tsx 文件组成。以下是我的jest.config.js 文件。
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
cacheDirectory: ".jest-cache",
coverageDirectory: ".jest-coverage",
coverageReporters: ["html", "text"],
testMatch: ["**/target/**/components/**/__tests__/**/*.[jt]s?(x)"],
transformIgnorePatterns: [
"node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)",
"/app-extensions/"
],
transform: {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.ts?$": "ts-jest",
'^.+\\.tsx?$': "babel-jest"
},
moduleNameMapper: {
"\\.(css|jpg|png|svg)$": "<rootDir>/empty-module.js"
},
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
},
};
但是当我构建应用程序时,会抛出以下错误并失败。我在这里做错了什么?我尝试使用 ts-jest 和 babel-jest 转换 tsx 文件,但都因此错误而失败。
【问题讨论】:
标签: reactjs typescript jestjs ts-jest