Closed sunjoong85 closed 5 years ago
Oops.
I think calling ' initializeTransactionalContext()' works fine.
I will close this issue.
describe('Reservation Management', () => {
let hostOrderService: HostOrderService;
let orderRepository: OrderRepository;
beforeAll(async () => {
initializeTransactionalContext();
const module = await Test.createTestingModule({
providers: [HostOrderService, OrderRepositoryMock, PaymentServiceMock],
}).compile();
hostOrderService = module.get<HostOrderService>(HostOrderService);
orderRepository = module.get<OrderRepository>(OrderRepository);
});
Sorry. It didn't work.
Without DB connection I got this error.
ConnectionNotFoundError: Connection "default" was not found.
I got it! Mock Transactional decorator
Problem
I got this message in my test codes
No CLS namespace defined in your app ... please call initializeTransactionalContext() before application start.
Question
Are there any ways to mock @Transactional() in my test codes?
My test codes are below.
Furthermore, is it possible to manage transactions in a service layer without this hook? Currently, NestJS integration is not possible to control typeorm transaction features among services, not repositories.
Great job! Thanks!