Skip to content

Commit

Permalink
use experimentalRollbackInTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Quramy committed Mar 26, 2024
1 parent 85f9367 commit 7ee8ea5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions jest.config.mjs
Expand Up @@ -6,5 +6,6 @@ export default {
setupFilesAfterEnv: [],
testEnvironmentOptions: {
verboseQuery: true,
enableExperimentalRollbackInTransaction: true,
},
};
15 changes: 12 additions & 3 deletions src/index.test.ts
Expand Up @@ -28,9 +28,18 @@ test(ensureUser.name, async () => {
// succeed
expect(await ensureUser(jestPrisma.client, data)).toBe(true);

// succeed
expect(await ensureUser(jestPrisma.client, data)).toBe(true);
try {
await jestPrisma.client.$transaction(async () => {
// succeed
expect(await ensureUser(jestPrisma.client, data)).toBe(true);
throw new Error();
});
} catch {}

// fail
// succeed
expect(await jestPrisma.client.user.count()).toBe(1);
});

test("count user", async () => {
expect(await jestPrisma.client.user.count()).toBe(0);
});

0 comments on commit 7ee8ea5

Please sign in to comment.