-1
enzimeとjestへのアップグレードとともに、React 16にアップグレードする前に多くのテストが正しく機能していました。私は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"
]
}
に冗談のコンフィグにこの2つのファイルを追加しました。しかし、私はまだ私のテストが正常に動作して見ていませんよ。それは、この行だったトリガーそのすべて
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