【发布时间】:2020-11-25 07:14:30
【问题描述】:
我正在修复我们预先存在的项目的一些测试,我遇到了这个错误:
FAIL src/components/changelog/__test__/ChangeLogOverView.test.tsx
● Test suite failed to run
TypeError: Cannot create property '__packages__' on boolean 'true'
at Object.setVersion (node_modules/@uifabric/set-version/src/setVersion.ts:7:51)
at Object.<anonymous> (node_modules/@uifabric/set-version/src/index.ts:4:1)
at Object.<anonymous> (node_modules/office-ui-fabric-react/src/version.ts:3:3)
这是我的 jest.config.js:
module.exports = {
"name": "",
// Setup Jest
"roots": [
"<rootDir>/src"
],
"testEnvironment": "node",
"transformIgnorePatterns": ["/node_modules/"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleNameMapper": {
'office-ui-fabric-react/lib/(.*)$': 'office-ui-fabric-react/lib-commonjs/$1'
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"globals": {
"window": true
},
// Setup Enzyme
"snapshotSerializers": ["enzyme-to-json/serializer"],
"setupTestFrameworkScriptFile": "<rootDir>/src/setupEnzyme.ts",
}
我试图在网上搜索一些修复方法,但找不到任何东西
【问题讨论】:
-
你能分享你的笑话配置吗?
-
@tmhao2005 我把它添加到我的问题中
-
你用布尔值替换了全局窗口对象,你想做什么?
标签: javascript reactjs jestjs babel-jest