Skip to content

Commit

Permalink
Add fabbrica example
Browse files Browse the repository at this point in the history
  • Loading branch information
hokaccha committed Mar 24, 2024
1 parent f44e7d3 commit d5dd837
Show file tree
Hide file tree
Showing 13 changed files with 4,315 additions and 0 deletions.
4 changes: 4 additions & 0 deletions example/with-fabbrica/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
# Keep environment variables out of version control
.env
__generated__
8 changes: 8 additions & 0 deletions example/with-fabbrica/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Setup PostgreSQL server and run following commands.

```
$ npm install
$ npm run migrate
$ npm run generate
$ npm run test
```
7 changes: 7 additions & 0 deletions example/with-fabbrica/cleaner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Prisma, PrismaClient } from "@prisma/client";
import { PrismaCleaner } from "../../src";

export const cleaner = new PrismaCleaner({
prisma: new PrismaClient(),
models: Prisma.dmmf.datamodel.models,
});
5 changes: 5 additions & 0 deletions example/with-fabbrica/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { cleaner } from "./cleaner";

export default async function setup() {
await cleaner.cleanupAllTables();
}
16 changes: 16 additions & 0 deletions example/with-fabbrica/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Config } from "jest";

const config: Config = {
moduleFileExtensions: ["js", "json", "ts"],
rootDir: ".",
testEnvironment: "node",
testRegex: ".test.ts$",
transform: {
"^.+\\.ts$": "ts-jest",
},
maxWorkers: 1,
globalSetup: "<rootDir>/global-setup.ts",
setupFilesAfterEnv: ["<rootDir>/setup.ts"],
};

export default config;
Loading

0 comments on commit d5dd837

Please sign in to comment.