我需要测试我的代码。我们正处于从Angular 1.5迁移到React的中间阶段,我们的Angular文件扩展名为.jsa,我们的React文件扩展名为.js。
问题:正如预期的那样,Jest无法理解文件扩展名.jsa。
这是package.json中我开玩笑的配置:
"jest": {
"collectCoverage": false,
"setupTestFrameworkScriptFile": "./jest.setup.js",
"testMatch": [
"**/app/**/*.spec.js"
],
"moduleNameMapper": {
"\\.(svg)$": "<rootDir>/test/svg.mock.js",
"^Store/(.*)$": "<rootDir>/app/webapp/modules/store/$1",
"^App/(.*)$": "<rootDir>/app/$1",
"Common(.*)$": "<rootDir>/app/common/$1",
"ProfileCapture(.*)$": "<rootDir>/app/profile_capture/$1",
"^Helpers/(.*)$": "<rootDir>/app/common/helpers/$1",
"PageKit": "<rootDir>/app/common/components/PageKit"
},
"verbose": false
}
我试图添加一行moduleNameMapper:
"^App/(.*)[\\.]jsa$": "<rootDir>/app/$1.js"
但是似乎与之冲突
"^App/(.*)$": "<rootDir>/app/$1"
我的正则表达式有什么问题?