Personal-Data-Linkage-Module / pxr-operator-service

MIT License
1 stars 2 forks source link

Unit Testに失敗する #6

Open nmatsui opened 1 year ago

nmatsui commented 1 year ago

現在の状況

npm run test:unitを実行すると、2件のエラーが発生する

環境

エラーメッセージ

nmatsui@:pxr-operator-service (main *=)$ npm run test:unit

> operator-service@1.0.0 test:unit /Users/nmatsui/Documents/code/Personal-Data-Linkage-Module/pxr-operator-service
> jest --coverage --forceExit --detectOpenHandles --runInBand --config=jest.unit.config.js --logHeapUsage

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
 PASS  src/tests/13-01.UserInfo.spec.ts (12.643 s, 508 MB heap size)
 PASS  src/tests/04-01.OperatorUpdate.spec.ts (578 MB heap size)
 PASS  src/tests/01-01.OperatorAdd.spec.ts (639 MB heap size)
 PASS  src/tests/16-01.IndSmsVerificate.spec.ts (693 MB heap size)
 PASS  src/tests/05-01.OperatorDelete.spec.ts (753 MB heap size)
 PASS  src/tests/06-01.OperatorLogin.spec.ts (401 MB heap size)
 PASS  src/tests/10-01.PasswordReset.spec.ts (460 MB heap size)
 PASS  src/tests/02-01.OperatorGetByType.spec.ts (518 MB heap size)
 FAIL  src/tests/09-01.OperatorSession.spec.ts (558 MB heap size)
  ● operator API › セッション確認 › 正常(appロールなし)

    expect(received).toBe(expected) // Object.is equality

    Expected: 200
    Received: 401

      333 |
      334 |             // レスポンスチェック
    > 335 |             expect(response.status).toBe(200);
          |                                     ^
      336 |             expect(response.body.operatorId).toBe(4);
      337 |             expect(response.body.loginId).toBe('app_staff02');
      338 |             expect(response.body.passwordChangedFlg).toBe(false);

      at src/tests/09-01.OperatorSession.spec.ts:335:37
      at fulfilled (src/tests/09-01.OperatorSession.spec.ts:5:58)
          at runMicrotasks (<anonymous>)

 PASS  src/tests/08-01.OperatorLogout.spec.ts (605 MB heap size)
 PASS  src/tests/04-04.OperatorUpdate.libisAllAuthMemberExistsOtherThisIdError.spec.ts (661 MB heap size)
 PASS  src/tests/07-01.OperatorOneTimeLogin.spec.ts (706 MB heap size)
 PASS  src/tests/03-01.OperatorGetById.spec.ts (762 MB heap size)
 PASS  src/tests/14-01.RequestArrayValidator.spec.ts (804 MB heap size)
 PASS  src/tests/11-01.SecurityTest.password.spec.ts (856 MB heap size)
 PASS  src/tests/06-04.OperatorLogin.spec.ts (903 MB heap size)
 PASS  src/tests/17-01.SsoLogin.spec.ts (957 MB heap size)
 FAIL  src/tests/16-02.IndSmsVerificateVerifiy.spec.ts (1005 MB heap size)
  ● operator API › SMS検証コード検証 › 正常

    expect(received).toBe(expected) // Object.is equality

    Expected: 200
    Received: 400

      100 |                     smsVerificationCode: '123456'
      101 |                 }));
    > 102 |             expect(response.status).toBe(200);
          |                                     ^
      103 |             expect(JSON.stringify(response.body)).toBe(JSON.stringify(
      104 |                 { result: 'success' }
      105 |             ));

      at src/tests/16-02.IndSmsVerificateVerifiy.spec.ts:102:37
      at fulfilled (src/tests/16-02.IndSmsVerificateVerifiy.spec.ts:5:58)
          at runMicrotasks (<anonymous>)

 PASS  src/tests/12-01.RoleAndAuth.spec.ts (1049 MB heap size)
 PASS  src/tests/15-01.IdentifyCode.spec.ts (1099 MB heap size)
 PASS  src/tests/04-02.OperatorUpdate.libgetOperatorError.spec.ts (1152 MB heap size)
 PASS  src/tests/05-04.OperatorCancelDelete.spec.ts (1197 MB heap size)
 PASS  src/tests/05-02.OperatorDelete.libgetOperatorError.spec.ts (636 MB heap size)
 PASS  src/tests/06-02.OperatorLogin.GeneratesSessionIdIfAlreadyUse.spec.ts (681 MB heap size)
 PASS  src/tests/05-03.OperatorDelete.RequestFromAnotherUser.spec.ts (722 MB heap size)
 PASS  src/tests/01-02.OperatorAdd.libgetOperatorError.spec.ts (776 MB heap size)
 PASS  src/tests/04-03.OperatorUpdate.libisSessionIdExistsError.spec.ts (817 MB heap size)
 PASS  src/tests/06-03.OperatorLogin.GeneratesLoginIdIfAlreadyUse.spec.ts (863 MB heap size)
-------------------------------------------------|---------|----------|---------|---------|---------------------------------
File                                             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------------------------------------|---------|----------|---------|---------|---------------------------------
All files                                        |    98.1 |    96.34 |   99.47 |   97.99 |
 repositories/postgres                           |   96.43 |    88.17 |   97.33 |   95.85 |
  IdentifyCodeEntity.ts                          |   67.86 |       50 |     100 |   57.14 | 51-59
  IdentifyCodeRepository.ts                      |     100 |      100 |     100 |     100 |
  LoginHistory.ts                                |     100 |      100 |     100 |     100 |
  LoginHistoryOperation.ts                       |     100 |      100 |     100 |     100 |
  ManageBlockInfo.ts                             |     100 |      100 |     100 |     100 |
  OneTimeLoginCodeEntity.ts                      |     100 |      100 |     100 |     100 |
  OneTimeLoginCodeRepository.ts                  |     100 |      100 |     100 |     100 |
  OperatorEntity.ts                              |     100 |      100 |     100 |     100 |
  OperatorRepository.ts                          |   98.02 |    86.21 |     100 |   98.02 | 527,561
  PasswordHistory.ts                             |     100 |      100 |     100 |     100 |
  PasswordHistoryOperation.ts                    |     100 |      100 |     100 |     100 |
  RoleSettingEntity.ts                           |     100 |      100 |     100 |     100 |
  RoleSettingRepository.ts                       |     100 |      100 |     100 |     100 |
  SessionEntity.ts                               |     100 |      100 |     100 |     100 |
  SessionRepository.ts                           |   86.96 |      100 |   88.89 |   86.96 | 108-110
  SmsVerificationCode.ts                         |     100 |      100 |     100 |     100 |
  SmsVerificationCodeOperation.ts                |   82.14 |     62.5 |      75 |   82.14 | 75,96-111
  UserInformationEntity.ts                       |     100 |      100 |     100 |     100 |
  UserInformationRepository.ts                   |     100 |      100 |     100 |     100 |
 resources                                       |   99.71 |      100 |     100 |   99.69 |
  IdentifyCodeController.ts                      |     100 |      100 |     100 |     100 |
  LoginController.ts                             |     100 |      100 |     100 |     100 |
  LogoutController.ts                            |     100 |      100 |     100 |     100 |
  OperatorController.ts                          |     100 |      100 |     100 |     100 |
  PasswordController.ts                          |     100 |      100 |     100 |     100 |
  SessionController.ts                           |     100 |      100 |     100 |     100 |
  SmsVerificateController.ts                     |   97.14 |      100 |     100 |   96.97 | 72
  UserInfoController.ts                          |     100 |      100 |     100 |     100 |
 resources/dto                                   |   99.29 |    97.46 |     100 |   99.28 |
  GetByOperatorIdResDto.ts                       |   97.67 |    96.15 |     100 |   97.67 | 102
  GetOperatorWithTypeReqDto.ts                   |     100 |      100 |     100 |     100 |
  IdAAsOperatorOrUserReqDto.ts                   |     100 |      100 |     100 |     100 |
  NewPasswordReqDto.ts                           |     100 |      100 |     100 |     100 |
  OperatorIdReqDto.ts                            |     100 |      100 |     100 |     100 |
  PostAddUserInformationReqDto.ts                |     100 |      100 |     100 |     100 |
  PostIdentifyCodeReqDto.ts                      |     100 |      100 |     100 |     100 |
  PostIndLoginOneTimeReqDto.ts                   |     100 |      100 |     100 |     100 |
  PostIndLoginReqDto.ts                          |     100 |      100 |     100 |     100 |
  PostIndLoginSsoReqDto.ts                       |     100 |      100 |     100 |     100 |
  PostIndSmsVerificateReqDto.ts                  |     100 |      100 |     100 |     100 |
  PostIndSmsVerificateVerifiyReqDto.ts           |     100 |      100 |     100 |     100 |
  PostLoginReqDto.ts                             |     100 |      100 |     100 |     100 |
  PostLoginResDto.ts                             |     100 |      100 |     100 |     100 |
  PostLogoutReqDto.ts                            |     100 |      100 |     100 |     100 |
  PostOperatorAddReqDto.ts                       |     100 |      100 |     100 |     100 |
  PostOperatorAddResDto.ts                       |   96.36 |    94.74 |     100 |   96.36 | 133,148
  PostSessionReqDto.ts                           |     100 |      100 |     100 |     100 |
  PostSessionResDto.ts                           |     100 |      100 |     100 |     100 |
  PostUserInfoListReqDto.ts                      |     100 |      100 |     100 |     100 |
  PostUserInfoSearchReqDto.ts                    |     100 |      100 |     100 |     100 |
  PostUserInfoSearchResDto.ts                    |     100 |      100 |     100 |     100 |
  PutByOperatorIdReqDto.ts                       |     100 |      100 |     100 |     100 |
  PutByOperatorIdResDto.ts                       |     100 |      100 |     100 |     100 |
  UserInformationDto.ts                          |     100 |      100 |     100 |     100 |
 resources/validator                             |     100 |      100 |     100 |     100 |
  GetByOperatorTypeRequestValidator.ts           |     100 |      100 |     100 |     100 |
  IdAsOperatorOrUserValidator.ts                 |     100 |      100 |     100 |     100 |
  LoginRequestValidator.ts                       |     100 |      100 |     100 |     100 |
  OperatorIdParamsValidator.ts                   |     100 |      100 |     100 |     100 |
  PostIdentifyCodeRequestValidator.ts            |     100 |      100 |     100 |     100 |
  PostIndLoginOneTimeRequestValidator.ts         |     100 |      100 |     100 |     100 |
  PostIndLoginRequestValidator.ts                |     100 |      100 |     100 |     100 |
  PostIndLoginSsoRequestValidator.ts             |     100 |      100 |     100 |     100 |
  PostIndSmsVerificateRequestValidator.ts        |     100 |      100 |     100 |     100 |
  PostIndSmsVerificateVerifiyRequestValidator.ts |     100 |      100 |     100 |     100 |
  PostLoginOneTimeRequestValidator.ts            |     100 |      100 |     100 |     100 |
  PostLoginSsoRequestValidator.ts                |     100 |      100 |     100 |     100 |
  PostOperatorAddRequestValidator.ts             |     100 |      100 |     100 |     100 |
  PostSessionRequestValidator.ts                 |     100 |      100 |     100 |     100 |
  PostUserInfoListRequestValidator.ts            |     100 |      100 |     100 |     100 |
  PostUserInfoRequestValidator.ts                |     100 |      100 |     100 |     100 |
  PostUserInfoSearchRequestValidator.ts          |     100 |      100 |     100 |     100 |
  PutOperatorRepRequestValidator.ts              |     100 |      100 |     100 |     100 |
  PutPasswordRequestValidator.ts                 |     100 |      100 |     100 |     100 |
  UserInformationRequestValidator.ts             |     100 |      100 |     100 |     100 |
 services                                        |   97.39 |    96.35 |     100 |   97.31 |
  IdService_Stub.ts                              |     100 |      100 |     100 |     100 |
  IdentifyCodeService.ts                         |     100 |      100 |     100 |     100 |
  LoginService.ts                                |   90.87 |    94.52 |     100 |    90.7 | 260-272,290-302,477,486
  LogoutService.ts                               |   97.92 |    91.67 |     100 |   97.78 | 60
  OperatorService.ts                             |   98.95 |    96.58 |     100 |   98.93 | 484,508,559,1161-1162,1190,1278
  PasswordService.ts                             |     100 |      100 |     100 |     100 |
  SessionService.ts                              |   97.01 |    85.71 |     100 |   96.88 | 65-66
  SmsVerificateService.ts                        |   94.64 |       90 |     100 |   94.34 | 95-99
  UserInfoService.ts                             |     100 |    98.91 |     100 |     100 | 177
 services/dto                                    |     100 |      100 |     100 |     100 |
  IdentifyCodeServiceDto.ts                      |     100 |      100 |     100 |     100 |
  LoginServiceDto.ts                             |     100 |      100 |     100 |     100 |
  LogoutServiceDto.ts                            |     100 |      100 |     100 |     100 |
  OperatorServiceDto.ts                          |     100 |      100 |     100 |     100 |
  PasswordServiceDto.ts                          |     100 |      100 |     100 |     100 |
  SessionServiceDto.ts                           |     100 |      100 |     100 |     100 |
  SmsVerificateServiceDto.ts                     |     100 |      100 |     100 |     100 |
  UserInfoServiceDto.ts                          |     100 |      100 |     100 |     100 |
-------------------------------------------------|---------|----------|---------|---------|---------------------------------

Summary of all failing tests
 FAIL  src/tests/09-01.OperatorSession.spec.ts (558 MB heap size)
  ● operator API › セッション確認 › 正常(appロールなし)

    expect(received).toBe(expected) // Object.is equality

    Expected: 200
    Received: 401

      333 |
      334 |             // レスポンスチェック
    > 335 |             expect(response.status).toBe(200);
          |                                     ^
      336 |             expect(response.body.operatorId).toBe(4);
      337 |             expect(response.body.loginId).toBe('app_staff02');
      338 |             expect(response.body.passwordChangedFlg).toBe(false);

      at src/tests/09-01.OperatorSession.spec.ts:335:37
      at fulfilled (src/tests/09-01.OperatorSession.spec.ts:5:58)
          at runMicrotasks (<anonymous>)

 FAIL  src/tests/16-02.IndSmsVerificateVerifiy.spec.ts (1005 MB heap size)
  ● operator API › SMS検証コード検証 › 正常

    expect(received).toBe(expected) // Object.is equality

    Expected: 200
    Received: 400

      100 |                     smsVerificationCode: '123456'
      101 |                 }));
    > 102 |             expect(response.status).toBe(200);
          |                                     ^
      103 |             expect(JSON.stringify(response.body)).toBe(JSON.stringify(
      104 |                 { result: 'success' }
      105 |             ));

      at src/tests/16-02.IndSmsVerificateVerifiy.spec.ts:102:37
      at fulfilled (src/tests/16-02.IndSmsVerificateVerifiy.spec.ts:5:58)
          at runMicrotasks (<anonymous>)

Test Suites: 2 failed, 26 passed, 28 total
Tests:       2 failed, 363 passed, 365 total
Snapshots:   0 total
Time:        38.123 s
Ran all test suites.
jest-html-reporter >> Report generated (./coverage-unit/report.html)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! operator-service@1.0.0 test:unit: `jest --coverage --forceExit --detectOpenHandles --runInBand --config=jest.unit.config.js --logHeapUsage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the operator-service@1.0.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nmatsui/.npm/_logs/2023-05-25T00_05_05_447Z-debug.log