// __tests__/api.contract.test.ts test("POST /resource returns correct error shape on validation failure", async () => { const response = await fetch("/resource", { method: "POST", body: JSON.stringify({ field: "invalid" }), }); const error = await response.json(); expect(error).toMatchObject({ success: false, error: "VALIDATION_ERROR", details: { validationErrors: expect.any(Array), }, }); expect(error).not.toHaveProperty("stack"); // 👈 NO LEAKS }); __ __