-1
我有很多測試,在升級到React 16之前正常工作,以及各自升級到enzime和jest。我跟着the instructions,在我的package.json進口在反應16測試與酶和笑話失敗
"jest": {
"globals": {
"rootLevel": "/portal"
},
"moduleNameMapper": {
"components": "<rootDir>/../components",
"\\.(jpg|jpeg|png|gif|svg|woff|woff2)$": "<rootDir>/_tests/__mocks/fileMock.js"
},
"setupFiles": [
"<rootDir>/_tests/__config/shim.js",
"<rootDir>/_tests/__config/enzyme-setup.js"
]
}
將這兩個文件複製到開玩笑CONFIGS但我仍然沒有看到我的測試運行正常。我的大多數測試中拋出相同的錯誤這樣的:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
Check the render method of `WrapperComponent`.
at invariant (node_modules/fbjs/lib/invariant.js:42:15)
...
at mount (node_modules/enzyme/build/mount.js:19:10)
at Object.<anonymous> (_tests/MyTest.test.js:39:35)
所有觸發,這是該行:
const wrapper = mount(<MyComponent {...props} />)
據我所知,mount
仍然以同樣的酶3.所有我涉及渲染的測試失敗了。我錯過了什麼?
我沒有看到您發佈的URL任何提及「組件」。否則,該文件應該使用create-react-app自動生成。 – HoldOffHunger