前提・実現したいこと
jestでテスト対象のファイルのインポートでエラーが出ています。
テストファイル自体は、テスト対象ファイルを特定できているのですが、なぜかテスト対象のファイルのimportでエラーが起きています。
発生している問題・エラーメッセージ
ic-remake-info@0.1.0 test /Users/k.matsumoto/workspace/sbi-neotrade/sbi-neotrade-webclient > NODE_ENV=test jest FAIL tests/util.test.js ● Test suite failed to run Cannot find module 'config/const' from 'src/utils/util.js' Require stack: src/utils/util.js tests/util.test.js > 1 | import { app } from "config/const" | ^ at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11) at Object.<anonymous> (src/utils/dirUtil.js:1:1) Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 0.723 s Ran all test suites. npm ERR! Test failed. See above for more details.
該当のソースコード
package.json
1 "scripts": { 2 --- 3 "test": "NODE_ENV=test jest", 4 --- 5 }
babelrc
1{ 2 "env": { 3 "test": { 4 "plugins": [ 5 "transform-es2015-modules-commonjs" 6 ] 7 } 8 } 9}
util.test.js
1import { getExchangeName } from '../src/utils/util'; 2 3test('getExchangeName', () => { 4 expect(getExchangeName("1")).toBe("テスト"); 5});
おそらく、jestの設定がおかしいのかと思うのですが検討がつかないので回答をよろしくお願い致します。
あなたの回答
tips
プレビュー