-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