Software DevelopmentIntermediate 2 to 3 hours

Integration Testing an API Endpoint

Write tests that verify the database and API routing layers work together.

The Scenario

You are testing a `POST /users` endpoint. This endpoint receives JSON, hashes the password, saves the user to the database, and returns a 201 Created status.

The Brief

Write the integration test suite for the `POST /users` endpoint using Supertest and Jest. You must demonstrate how you mock or spin up a test database so you are not writing to the production database during tests.

Deliverables

  • The integration test code snippet
  • An explanation of the setup and teardown process (`beforeAll`, `afterEach`, etc.) for managing the test database state

Submission Guidance

Integration tests should test the whole request lifecycle. Make sure to test what happens when the database throws a duplicate email error (e.g., returning a 409 Conflict).

Submit Your Work

Your submission is graded against the rubric on the right. If you pass, you get a public Badge URL you can share on LinkedIn. There is no draft save, so work offline first and paste your finished response here.

This appears on your public Badge.

0/20000 charactersMarkdown supported

One per line or comma separated. Up to 5 links.

By submitting, you agree your submission text, name, and evaluation will appear on a public Badge URL.