@arthurfiorette/jest-prisma-core
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@arthurfiorette/jest-prisma-core

Utility class to build Jest environment for Prisma.

Usage

import type { Circus } from "@jest/types";
import type { JestEnvironmentConfig, EnvironmentContext } from "@jest/environment";
import { PrismaEnvironmentDelegate } from "@arthurfiorette/jest-prisma-core";

import Environment from "your-jest-environment";

export default class PrismaEnvironment extends Environment {
  private readonly delegate: PrismaEnvironmentDelegate;

  constructor(config: JestEnvironmentConfig, context: EnvironmentContext) {
    super(config, context);
    this.delegate = new PrismaEnvironmentDelegate(config, context);
  }

  async setup() {
    const jestPrisma = await this.delegate.preSetup();
    await super.setup();
    this.global.jestPrisma = jestPrisma;
  }

  handleTestEvent(event: Circus.Event) {
    return this.delegate.handleTestEvent(event);
  }

  async teardown() {
    await Promise.all([super.teardown(), this.delegate.teardown()]);
  }
}

LICENSE

MIT

/@arthurfiorette/jest-prisma-core/

    Package Sidebar

    Install

    npm i @arthurfiorette/jest-prisma-core

    Weekly Downloads

    0

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    11.7 kB

    Total Files

    9

    Last publish

    Collaborators

    • hazork