반응형
✅오늘 학습 Keyword
2023.06.21 - [실전프로젝트] - 230621 실전프로젝트20 [Nest.js] Jest로 Unit test code 짜기
프로젝트 마무리 단계에 접어들었고 CI/CD를 위한 UNIT TEST CODE 작성을 시작했다.
✅오늘 겪은 문제
아래와 같은 에러가 떴다.
● StoresRepository › updateCoord › 카톡에서 추출한 좌표를 postgresql에 저장
Nest can't resolve dependencies of the StoresRepository (StoresRepository, ?). Please make sure that the argument TablesRepository at index [1] is available in the RootTestModule context.
Potential solutions:
- Is RootTestModule a valid NestJS module?
- If TablesRepository is a provider, is it part of the current RootTestModule?
- If TablesRepository is exported from a separate @Module, is that module imported within RootTestModule?
@Module({
imports: [ /* the Module containing TablesRepository */ ]
})
10 |
11 | beforeEach(async () => {
> 12 | const module = await Test.createTestingModule({
| ^
13 | providers: [
14 | StoresRepository,
15 | {
at TestingInjector.lookupComponentInParentModules (../node_modules/@nestjs/core/injector/injector.js:247:19)
at TestingInjector.resolveComponentInstance (../node_modules/@nestjs/core/injector/injector.js:200:33)
at TestingInjector.resolveComponentInstance (../node_modules/@nestjs/testing/testing-injector.js:19:45)
at resolveParam (../node_modules/@nestjs/core/injector/injector.js:120:38)
at async Promise.all (index 1)
at TestingInjector.resolveConstructorParams (../node_modules/@nestjs/core/injector/injector.js:135:27)
at TestingInjector.loadInstance (../node_modules/@nestjs/core/injector/injector.js:61:13)
at TestingInjector.loadProvider (../node_modules/@nestjs/core/injector/injector.js:88:9)
at ../node_modules/@nestjs/core/injector/instance-loader.js:56:13
at async Promise.all (index 3)
at TestingInstanceLoader.createInstancesOfProviders (../node_modules/@nestjs/core/injector/instance-loader.js:55:9)
at ../node_modules/@nestjs/core/injector/instance-loader.js:40:13
at async Promise.all (index 1)
at TestingInstanceLoader.createInstances (../node_modules/@nestjs/core/injector/instance-loader.js:39:9)
at TestingInstanceLoader.createInstancesOfDependencies (../node_modules/@nestjs/core/injector/instance-loader.js:22:13)
at TestingInstanceLoader.createInstancesOfDependencies (../node_modules/@nestjs/testing/testing-instance-loader.js:9:9)
at TestingModuleBuilder.createInstancesOfDependencies (../node_modules/@nestjs/testing/testing-module.builder.js:97:9)
at TestingModuleBuilder.compile (../node_modules/@nestjs/testing/testing-module.builder.js:63:9)
at Object.<anonymous> (stores/stores.repository.spec.ts:12:20)
에러의 내용을 살펴보면 TablesRepository가 StoresRepository의 의존성으로 등록되어있지 않다는 뜻인데,
실제로 StoresRepository에 TablesRepository가 등록되어 있었지만 더이상 프로젝트에서 Tables 는 쓰이지 않기에 삭제해주었더니 해결되었다.
✅오늘 알게된 점 및 추후 학습 방향
service부분의 testcode도 구현할 예정이다.
반응형
'개발 > 프로젝트-식당 웨이팅 앱 FOOD LINE' 카테고리의 다른 글
Docker / CICD 란? (0) | 2023.06.23 |
---|---|
230623 실전프로젝트21 [Nest.js] 카카오맵 API에서 좌표 크롤링하기 (0) | 2023.06.23 |
230621 실전프로젝트19 [Nest.js] Jest로 Unit test code 짜기 (0) | 2023.06.21 |
230620 실전프로젝트18 [Nest.js] Jmeter로 부하테스트하기2 (0) | 2023.06.20 |
230619 실전프로젝트17 [Nest.js] Load balancer (0) | 2023.06.19 |