database에 연결 할 수 없다는 에러가 떴다
[ExceptionHandler] Unable to connect to the database.
DB 연결을 유지하기 위해서
beforeEach => beforeAll로 변경해주자 오류없이 테스트를 할 수 있었다.
Nest can't resolve dependencies of the ProductService (?, UserRepository).
Please make sure that the argument ProductRepository at index [0]
is available in the RootTestModule context.
Appmodule에서 DB연결을 위해 작성한 것과 같이 test를 위한 module에 똑같이 import해주면 해결된다.
ex:
imports: [
TypeOrmModule.forFeature([User, Product]),
UsersModule,
ProductModule,
TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: 'password,
database: 'shoppingmall',
entities: [User, Product, Category],
}),
],