CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/prisma-best-practices

Prisma ORM patterns — schema design, migrations, type-safe queries, testing, error handling, and performance

96

1.28x
Quality

95%

Does it follow best practices?

Impact

100%

1.28x

Average score across 3 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-3/

Integration Test Suite for Order Service

Problem/Feature Description

A backend engineering team has a Prisma-backed order service and needs a proper integration test suite. In the past, tests were unreliable: they sometimes passed when run individually but failed when run together. The root cause turned out to be shared state — tests were reading data written by previous tests, and some tests left records in the database that caused uniqueness errors in subsequent runs. The team wants to rewrite the test suite properly.

The service has three models: Product, Order, and OrderItem (OrderItem has foreign keys to both Order and Product). The tests should cover: creating an order with line items, looking up an existing order, and attempting to look up an order that doesn't exist.

The team uses Jest as the test runner with TypeScript support. They want the tests to be completely self-contained — each test should start from a known state and not depend on data from any other test.

Output Specification

Produce the following files:

  • test/order.test.ts — the test suite with at minimum 3 tests covering order creation, order retrieval (success), and order retrieval (not found)
  • .env.test — the environment file for the test database (use a SQLite file-based URL for simplicity: file:./test.db)

The test file should use a local prisma client instance (you can define it at the top of the test file). Do not install packages or run migrations — just write the source files.

Assume the service functions placeOrder and getOrderDetail are imported from ../src/order-service.

evals

tile.json