Skip to content

Commit

Permalink
Merge pull request #142 from Quramy/link_to_issue_141
Browse files Browse the repository at this point in the history
docs: Put a link to #141
  • Loading branch information
Quramy committed Mar 27, 2024
2 parents 84d12d5 + 83d2116 commit 13a4a60
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -370,7 +370,7 @@ See also https://github.com/Quramy/jest-prisma/issues/56.

If you are using [$transaction callbacks in Prisma with the feature to roll back in case of an error](https://www.prisma.io/docs/concepts/components/prisma-client/transactions#:~:text=If%20your%20application%20encounters%20an%20error%20along%20the%20way%2C%20the%20async%20function%20will%20throw%20an%20exception%20and%20automatically%20rollback%20the%20transaction.), that's ok too. :D

Set `enableExperimentalRollbackInTransaction` in testEnvironmentOptions to true.
Set `enableExperimentalRollbackInTransaction` in testEnvironmentOptions to `true`. This option allows nested transaction.

```js
/* jest.config.mjs */
Expand Down Expand Up @@ -410,6 +410,9 @@ it("test", async () => {
});
```

> [!TIP]
> The nested transaction is used to suppress PostgreSQL's `current transaction is aborted commands ignored until end of transaction block` error. See https://github.com/Quramy/jest-prisma/issues/141 if you want more details.
Internally, SAVEPOINT, which is formulated in the Standard SQL, is used.

Unfortunately, however, MongoDB does not support partial rollbacks within a Transaction using SAVEPOINT, so MongoDB is not able to reproduce rollbacks. In this case, do not set `enableExperimentalRollbackInTransaction` to true.
Expand Down

0 comments on commit 13a4a60

Please sign in to comment.