Skip to content

Prisma tests failing in CI due to missing Prisma client generation #3

@izadoesdev

Description

@izadoesdev

Problem

The Prisma tests (src/storage/prisma.test.ts) are currently excluded from the main test suite and fail to run in CI because the Prisma client is not generated before the tests execute.

Current CI Configuration

Looking at .github/workflows/test.yml, the workflow:

  1. Sets up PostgreSQL service (lines 25-37)
  2. Excludes Prisma tests from main test run: bun run test --exclude '**/prisma.test.ts' (line 56)
  3. Pushes the Prisma schema to the database (lines 63-66)
  4. Attempts to run Prisma tests (lines 68-71)

However, there's no step to generate the Prisma client between pushing the schema and running the tests.

Why This Fails

The Prisma test file imports from @prisma/client:

import { PrismaClient } from "@prisma/client";

This requires the Prisma client to be generated first using prisma generate, which currently doesn't happen in the CI workflow.

Expected Behavior

The Prisma tests should run successfully in CI and verify that the Prisma storage adapter works correctly with PostgreSQL.

Proposed Solution

Add a step to generate the Prisma client before running the tests:

- name: Generate Prisma client
  run: bunx prisma generate
  env:
    DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5432/keypal

- name: Push Prisma schema
  run: bunx prisma db push
  env:
    DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5432/keypal

- name: Run Prisma tests
  run: bun run test:prisma
  env:
    DATABASE_URL: postgresql://keypal:keypal_dev@localhost:5432/keypal

Additional Context

  • The prisma:generate script exists in package.json (line 69)
  • Docker Compose is set up for local PostgreSQL testing
  • Prisma schema is located at prisma/schema.prisma
  • Tests cover comprehensive scenarios including CRUD operations, tags, scopes, expiration, and performance testing

Related Files

  • .github/workflows/test.yml - CI workflow configuration
  • src/storage/prisma.test.ts - Prisma test suite (1068 lines)
  • src/storage/prisma.ts - Prisma storage adapter implementation
  • prisma/schema.prisma - Prisma schema definition
  • package.json - Contains prisma:generate script

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcitests

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions