Auto-generated tile from GitHub (10 skills)
92
94%
Does it follow best practices?
Impact
92%
1.16xAverage score across 44 eval scenarios
Advisory
Suggest reviewing before use
A logistics company has an existing Fastify inventory API that has never had automated tests. A junior developer recently introduced a regression that went unnoticed for two days because testing was done manually. The engineering lead wants a proper test suite added before the next release.
The API has three endpoints: one to list all inventory items with optional filtering by warehouse, one to create a new inventory item, and one to look up a single item by its SKU. The team uses Node.js 22 and does not want to introduce additional testing frameworks — they want to use whatever ships with Node.js directly.
Your task is to write a test suite for the provided API. The tests should cover: successful responses for all three endpoints, validation error responses (e.g., missing required fields, invalid data types), a 404 response for a SKU that does not exist, and filtering by warehouse.
The test suite must be runnable with a single command without installing any third-party testing frameworks (no jest, mocha, tap, vitest, or similar).
The following files are provided as inputs. Extract them before beginning.
=============== FILE: src/app.ts =============== import Fastify from 'fastify' import { Type, type Static } from '@sinclair/typebox' import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
const ItemSchema = Type.Object({ sku: Type.String({ minLength: 1 }), name: Type.String({ minLength: 1 }), warehouse: Type.String(), quantity: Type.Integer({ minimum: 0 }), })
const CreateItemSchema = Type.Object({ sku: Type.String({ minLength: 1 }), name: Type.String({ minLength: 1 }), warehouse: Type.String({ minLength: 1 }), quantity: Type.Integer({ minimum: 0 }), })
type Item = Static<typeof ItemSchema>
const items: Item[] = [ { sku: 'WIDGET-001', name: 'Blue Widget', warehouse: 'WH-A', quantity: 50 }, { sku: 'GADGET-002', name: 'Red Gadget', warehouse: 'WH-B', quantity: 10 }, { sku: 'THING-003', name: 'Green Thing', warehouse: 'WH-A', quantity: 200 }, ]
export function buildApp () { const app = Fastify({ logger: false }).withTypeProvider<TypeBoxTypeProvider>()
app.get('/', { schema: { querystring: Type.Object({ warehouse: Type.Optional(Type.String()), }), response: { 200: Type.Array(ItemSchema), }, }, }, async (request) => { const { warehouse } = request.query if (warehouse) { return items.filter(i => i.warehouse === warehouse) } return items })
app.get('/:sku', { schema: { params: Type.Object({ sku: Type.String() }), response: { 200: ItemSchema, 404: Type.Object({ error: Type.String() }), }, }, }, async (request, reply) => { const item = items.find(i => i.sku === request.params.sku) if (!item) { return reply.code(404).send({ error: 'Item not found' }) } return item })
app.post('/', { schema: { body: CreateItemSchema, response: { 201: ItemSchema, }, }, }, async (request, reply) => { const item = request.body items.push(item) return reply.code(201).send(item) })
return app } =============== END FILE ===============
Produce:
package.json with type: "module" and a test scriptsrc/app.ts (copy the provided file above, unchanged)test/inventory.test.ts (or .js) — the test suiteThe test script in package.json must run tests without any third-party test runner (no jest, mocha, tap, vitest, or similar packages).
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20
scenario-21
scenario-22
scenario-23
scenario-24
scenario-25
scenario-26
scenario-27
scenario-28
scenario-29
scenario-30
scenario-31
scenario-32
scenario-33
scenario-34
scenario-35
scenario-36
scenario-37
scenario-38
scenario-39
scenario-40
scenario-41
scenario-42
scenario-43
scenario-44
skills
documentation
fastify
init
linting-neostandard-eslint9
node
nodejs-core
rules
oauth
octocat
snipgrapher