Add integration tests for POST /todos and DELETE /todos/:id #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Add an integration test suite (using supertest against the Express app) that covers the two new endpoints added in the previous issue. The test file should import or start the Express app, not spawn a separate process. Add an
npm testscript to package.json that runs the suite. Tests must be self-contained: each test resets or accounts for shared in-memory state so they pass in isolation and together.Done criteria
test/api.test.js(ortest/api.spec.js)npm testexits with code 0id,title,done)supertestis listed as a devDependency in package.jsonHints
Export the Express
appobject from index.js without callingapp.listen()at module level (guard it withif (require.main === module)) so supertest can bind its own port. Use a test runner already available in Node (e.g., node:test + assert) to avoid adding an extra dependency, or add jest/mocha — either is fine as long asnpm testdrives it.Model
sonnet