atls / nestjs

NestJS Custom Workshop
BSD 3-Clause "New" or "Revised" License
33 stars 8 forks source link

[feature] coverage nestjs-tinkoff with tests #161

Closed talentumtuum closed 3 years ago

talentumtuum commented 3 years ago

С чем связан запрос на фичу?

необходимость в покрытии тестами

Расскажите как вы это себе видите

  1. Создать папку tests
  2. Создать файл в котором протестировать https://github.com/Atlantis-Lab/nestjs/blob/master/packages/nestjs-tinkoff/src/guards/request-verifier.guard.ts Моки для теста можно взять из тестов репозитория https://github.com/Atlantis-Lab/tinkoff-api
talentumtuum commented 3 years ago

При старте тестов выходит ошибка как в этом ижью https://github.com/nestjs/nest/issues/2190 Скорее всего проблема в actl-test -> ts-jest

TorinAsakura commented 3 years ago

При старте тестов выходит ошибка как в этом ижью https://github.com/nestjs/nest/issues/2190

Скорее всего проблема в actl-test -> ts-jest

И? Дальше-то что? У наших тестов в первой итерации в соседних пакетах всё ок

talentumtuum commented 3 years ago

@TorinAsakura значит код в соседних пакетах способен работать на es5. Этот не может

TorinAsakura commented 3 years ago

@tuogeniy Решение?

talentumtuum commented 3 years ago

@TorinAsakura нужно обновлять зависимости пакетов actl, он блочит

talentumtuum commented 3 years ago

лог ошибки

tuogeniy@mac nestjs % yarn run test yarn run v1.22.10 $ mctl test ts-jest[versions] (WARN) Version 24.9.0 of jest installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=26.0.0 <27.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions. ts-jest[config] (WARN) The option tsConfig is deprecated and will be removed in ts-jest 27, use tsconfig instead ts-jest[versions] (WARN) Version 24.9.0 of jest installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=26.0.0 <27.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions. ts-jest[config] (WARN) The option tsConfig is deprecated and will be removed in ts-jest 27, use tsconfig instead ts-jest[versions] (WARN) Version 24.9.0 of jest installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=26.0.0 <27.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions. ts-jest[config] (WARN) The option tsConfig is deprecated and will be removed in ts-jest 27, use tsconfig instead PASS packages/nestjs-map-errors-interceptor/tests/interceptor.test.ts (5.611s) PASS packages/server-scripts/tests/create-webpack-config.test.ts (6.558s) PASS packages/nestjs-signed-url/tests/generate-url.test.ts (6.687s) FAIL packages/nestjs-tinkoff/tests/request-verifier-guard.test.ts (18.06s) ● Guards › should prevent access (unauthorized)

TypeError: Class constructor Tinkoff cannot be invoked without 'new'

   8 | export class TinkoffService extends Tinkoff {
   9 |   public constructor(@Inject(TINKOFF_API_OPTIONS) options: TinkoffPublicOptions) {
> 10 |     super(options)
     |     ^
  11 |   }
  12 | }
  13 | 

  at new TinkoffService (packages/nestjs-tinkoff/src/services/tinkoff.service.ts:10:5)
  at Injector.instantiateClass (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:290:19)
  at callback (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:77:41)
  at Injector.resolveConstructorParams (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:118:24)
  at Injector.loadInstance (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:81:9)
  at Injector.loadProvider (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:38:9)
  at Injector.lookupComponentInImports (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:224:17)
  at Injector.lookupComponentInParentModules (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:190:33)
  at Injector.resolveComponentInstance (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:148:33)
  at resolveParam (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:102:38)
      at async Promise.all (index 0)
  at Injector.resolveConstructorParams (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:117:27)
  at Injector.loadInstance (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:81:9)
  at Injector.loadProvider (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/injector.js:38:9)
      at async Promise.all (index 3)
  at InstanceLoader.createInstancesOfProviders (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/instance-loader.js:43:9)
  at node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/instance-loader.js:28:13
      at async Promise.all (index 1)
  at InstanceLoader.createInstances (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/instance-loader.js:27:9)
  at InstanceLoader.createInstancesOfDependencies (node_modules/@nestjs/testing/node_modules/@nestjs/core/injector/instance-loader.js:17:9)
  at TestingModuleBuilder.compile (node_modules/@nestjs/testing/testing-module.builder.js:43:9)
TorinAsakura commented 3 years ago

@tuogeniy это проблема твоего гавнокода, а не проблема mctl или зависимостей

talentumtuum commented 3 years ago

@TorinAsakura почему? Код работает

TorinAsakura commented 3 years ago

@tuogeniy Потому что твоя ошибка никак не связана с инструментами тестирования. Они в порядке. Всё, что WARN != ERROR

talentumtuum commented 3 years ago

@TorinAsakura когда я запускаю тест через jest

yarn workspace @atlantis-lab/nestjs-tinkoff run jest

этой проблемы нет

TorinAsakura commented 3 years ago

@TorinAsakura когда я запускаю тест через jest

yarn workspace @atlantis-lab/nestjs-tinkoff run jest

этой проблемы нет

Сейчас закину пакет, попробуй с ним протестить, ток дебагер включи