Code Room
Vibe codingHard
Question
An AI agent wrote a TypeScript test for a function that charges a customer via a payment gateway and records the charge in the DB. It reports 100% line coverage. Here's the test:
test('charges customer and saves record', async () => { const gateway = { charge: jest.fn().mockResolvedValue({ id: 'ch_1' }) }; const db = { insert: jest.fn().mockResolvedValue(undefined) }; const svc = new BillingService(gateway, db); await svc.chargeAndRecord('cus_1', 500); expect(gateway.charge).toHaveBeenCalled(); expect(db.insert).toHaveBeenCalled();});The test is green and coverage is high. What is wrong with this as a verification of chargeAndRecord, and how would you make it actually meaningful?
What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.