質問編集履歴

1

書式の改善

2022/03/14 06:53

投稿

matsukazu
matsukazu

スコア2

test CHANGED
File without changes
test CHANGED
@@ -1,5 +1,42 @@
1
+
2
+
3
+ ### 前提・実現したいこと
4
+
1
5
  jestでテスト対象のファイルのインポートでエラーが出ています。
2
6
  テストファイル自体は、テスト対象ファイルを特定できているのですが、なぜかテスト対象のファイルのimportでエラーが起きています。
7
+
8
+ ### 発生している問題・エラーメッセージ
9
+
10
+ ```ログ
11
+ ic-remake-info@0.1.0 test /Users/k.matsumoto/workspace/sbi-neotrade/sbi-neotrade-webclient
12
+ > NODE_ENV=test jest
13
+
14
+ FAIL tests/util.test.js
15
+ ● Test suite failed to run
16
+
17
+ Cannot find module 'config/const' from 'src/utils/util.js'
18
+
19
+ Require stack:
20
+ src/utils/util.js
21
+ tests/util.test.js
22
+
23
+ > 1 | import { app } from "config/const"
24
+ | ^
25
+
26
+ at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
27
+ at Object.<anonymous> (src/utils/dirUtil.js:1:1)
28
+
29
+ Test Suites: 1 failed, 1 total
30
+ Tests: 0 total
31
+ Snapshots: 0 total
32
+ Time: 0.723 s
33
+ Ran all test suites.
34
+ npm ERR! Test failed. See above for more details.
35
+
36
+ ```
37
+
38
+ ### 該当のソースコード
39
+
3
40
  ```package.json
4
41
  "scripts": {
5
42
  ---
@@ -28,31 +65,5 @@
28
65
  });
29
66
  ```
30
67
 
31
- ```ログ
32
- ic-remake-info@0.1.0 test /Users/k.matsumoto/workspace/sbi-neotrade/sbi-neotrade-webclient
33
- > NODE_ENV=test jest
68
+ おそらく、jestの設定がおかしいのかと思うのですが検討がつかないので回答をよろしくお願い致します。
34
69
 
35
- FAIL tests/util.test.js
36
- ● Test suite failed to run
37
-
38
- Cannot find module 'config/const' from 'src/utils/util.js'
39
-
40
- Require stack:
41
- src/utils/util.js
42
- tests/util.test.js
43
-
44
- > 1 | import { app } from "config/const"
45
- | ^
46
-
47
- at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
48
- at Object.<anonymous> (src/utils/dirUtil.js:1:1)
49
-
50
- Test Suites: 1 failed, 1 total
51
- Tests: 0 total
52
- Snapshots: 0 total
53
- Time: 0.723 s
54
- Ran all test suites.
55
- npm ERR! Test failed. See above for more details.
56
- ```
57
-
58
- おそらく、jestの設定がおかしいのかと思うのですが検討がつかないので回答をよろしくお願い致します。