Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prisma-extensions/factory

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-extensions/factory

Factory enables you to easily create and build database records for testing or seeding purposes.

  • 0.1.0-canary.20230204011658
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

@prisma-extensions/factory

  • @prisma-extensions/factory - Create factories
  • @prisma-extensions/msoft-delete - Enable a deletedAt field.
  • @prisma-extensions/truncate - Truncate

Challenges

  • When using model.$allModels you can't get the model the method is being acted on.
  • When using model.$allModels you can't get the types of the model the method is being acted on.

Blockers

Proposed API

  • Utilizes @prisma-extensions/truncate
const xprisma = new PrismaClient()
  .$extends(factoryExtension)
  .$extends(truncateExtension)

const UserFactory = xprisma.user.createFactory({
  firstName: "Jane",
  lastName: "Doe",
})

describe("Post", () => {
  describe("Standard" () => {
    afterEach(async () => {
      await xprisma.$truncate()
    })

    test("example", async () => {
      const user = UserFactory.build()
      const post = await PostFactory.create({
        title: "Foo",
        content: "Bar",
        author: {
          create: user,
        },
      })

      // ...
    })
  })

  // Tests should be isolated (use sparingly)
  describe("Persistent Record", () => {
    const user = UserFactory.create()

    afterAll(async () => {
      await xprisma.$truncate({ only: ["User"] })
    })

    afterEach(async () => {
      await xprisma.$truncate({ exclude: ["User"] })
    })

    test("example", async () => {
      const post = await PostFactory.create({
        title: "Foo",
        content: "Bar",
        author: {
          connect: { id: user.id },
        },
      })

      // ...
    })
  })
})

Learn more about the power of Turborepo:

  • Pipelines
  • Caching
  • Remote Caching
  • Filtering
  • Configuration Options
  • CLI Usage

Keywords

FAQs

Package last updated on 04 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc