Hi all, I'm using `$transaction` API and wonder ho...
# orm-help
ł
Hi all, I'm using
$transaction
API and wonder how should I write
jest
unit tests that checks if transaction was rollbacked when error occurred:
Copy code
await this.prisma.$transaction(async (prisma) => {
  const user = await prisma.user.create({ data });
  await this.mailerService.sendEmail(user);
});

//...
jest
  .spyOn(mailerService, 'sendEmail')
  .mockImplementation(async (user: User) => {
    throw new Error('Email sent error');
  });
👀 1
1
j
You can throw and error then prisma will rollback https://github.com/prisma/prisma/issues/1844 Feature request https://github.com/prisma/prisma/issues/12458
🙌 1