我在我的React项目中使用Semantic-UI。 它运作良好。但有时在使用Jest进行单元测试时会显示错误。
这是错误消息
console.error node_modules/semantic-ui-react/dist/commonjs/lib/debug.js:25
Semantic-UI-React could not enable debug.
console.error node_modules/semantic-ui-react/dist/commonjs/lib/debug.js:26
TypeError: Cannot read property 'debug' of undefined
at Object.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/semantic-ui-react/dist/commonjs/lib/debug.js:22:33)
at Runtime._execModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:513:13)
at Runtime.requireModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:329:14)
at Runtime.requireModuleOrMock (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:405:19)
at Object.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/semantic-ui-react/dist/commonjs/lib/index.js:77:14)
at Runtime._execModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:513:13)
at Runtime.requireModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:329:14)
at Runtime.requireModuleOrMock (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:405:19)
at Object.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/semantic-ui-react/dist/commonjs/addons/Responsive/Responsive.js:43:12)
at Runtime._execModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:513:13)
at Runtime.requireModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:329:14)
at Runtime.requireModuleOrMock (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:405:19)
at Object.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/semantic-ui-react/dist/commonjs/addons/Responsive/index.js:8:19)
at Runtime._execModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:513:13)
at Runtime.requireModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:329:14)
at Runtime.requireModuleOrMock (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:405:19)
at Object.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/semantic-ui-react/dist/commonjs/index.js:7:19)
at Runtime._execModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:513:13)
at Runtime.requireModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:329:14)
at Runtime.requireModuleOrMock (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:405:19)
at Object.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/src/FamilyViewWithController/index.js:4:24)
at Runtime._execModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:513:13)
at Runtime.requireModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:329:14)
at Runtime.requireModuleOrMock (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:405:19)
at Object.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/src/FamilyViewWithController/index.test.js:1:232)
at Runtime._execModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:513:13)
at Runtime.requireModule (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:329:14)
at jasmine2 (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-jasmine2/build/index.js:97:11)
at runTest (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/build/runTest.js:85:10)
at module.exports (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/jest-cli/build/TestWorker.js:87:5)
at handle (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (/home/ubuntu/work/node/suite/suite-cloud-app/client/node_modules/worker-farm/lib/child/index.js:51:3)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emit (internal/child_process.js:772:12)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
这很奇怪。 -有时会出现,有时却不会 -有时它出现在一个组件中,有时它不出现在那个组件中。 -它不会出现少量组件。但它包含很多组件。 -但是即使出现此问题,测试也始终会通过。
我正在使用的测试命令是
CI=true NODE_ENV=test react-scripts test --env=jsdom --no-cache
对此有何想法?我确实希望您的团队解决此问题或让我知道如何解决它。
致谢。
答案 0 :(得分:0)
这是一个错误,已在https://github.com/Semantic-Org/Semantic-UI-React/pull/3485中修复,并在0.86.0中发布。