N予備校の4-17「【サービス開発2】プロジェクトの作成と認証の実装
」にて、Routerオブジェクトをテストしていたとき、、、
エラーログ
FAIL test/test.js (49.46s)
/login
✕ ログインのためのリンクが含まれる (14759ms)
● /login › ログインのためのリンクが含まれる
: Timeout - Async callback was not invoked within the 10000ms timeout specified by jest.setTimeout.Timeout - Asyn
c callback was not invoked within the 10000ms timeout specified by jest.setTimeout.Error:
4 |
5 | describe('/login', () => {
> 6 | test('ログインのためのリンクが含まれる', () => {
| ^
7 | return request(app)
8 | .get('/login')
9 | .expect('Content-Type', 'text/html; charset=utf-8')
at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
at Suite.<anonymous> (test/test.js:6:3)
at Object.<anonymous> (test/test.js:5:1)
GET /login 200 14665.183 ms - 170
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 73.928s
Ran all test suites.
Force exiting Jest: Have you considered using `--detectOpenHandles` to detect async operations that kept running afte
r all tests finished?
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
こんなエラーが!
原因
Timeout - Async callback was not invoked within the 10000ms timeout specified by jest.setTimeout.Timeout
というところからPCに負荷がかかったり、メモリの影響で時間がかかってしまうみたい。
結論
package.json
"scripts": {
"start": "node ./bin/www",
"test": "jest --testTimeout=10000 --forceExit"
},
の--testTimeout=10000
を自分の環境(メモリなど)に合うように15000
とかに調節してあげる
だから、package.jsonは
package.json
"scripts": {
"start": "node ./bin/www",
"test": "jest --testTimeout=15000 --forceExit"
},
などにしてあげるとOKです!