Module 12 · Lesson 3

Testing and Deployment

Ship safely. Pre-deploy checks, smoke tests, and rollback plans for when something goes wrong.

Audio: Testing and Deployment
0:000:00

Testing and Deployment

Shipping is not the end of the work; it is the moment when real users meet your code. A repeatable deployment process, with checks at every step and a way back when things break, separates calm releases from late-night incidents.

The Testing Pyramid

The classic guidance is to have many fast unit tests, fewer integration tests, and even fewer end-to-end tests. Unit tests give quick feedback during development. Integration tests catch wiring problems between modules. End-to-end tests verify that the whole system works for a real user flow. Skipping any layer leaves a hole.

Run the fast tests on every commit. Run the slower ones before every deploy.

Pre-Deploy Checks

Before code reaches production, a pipeline should:

  • Run the full automated test suite
  • Lint and type-check the code
  • Build the artifact (binary, container image, bundle)
  • Run a security scan against dependencies

If any step fails, the deploy stops. The example shows this stage-by-stage and exits with success: false when a stage fails.

Smoke Tests

A smoke test is a tiny set of checks against the freshly deployed system. It hits a few critical endpoints, makes sure the database is reachable, and verifies a sample request works end to end. If smoke tests fail, the deploy is broken even if every prior stage passed. The deploy must abort and roll back.

Rollback Plans

Every deploy should be reversible. Common patterns include keeping the previous version live alongside the new one (blue-green deployment), rolling out gradually to a fraction of traffic (canary release), and keeping the previous container image easy to redeploy.

The example reverses the list of completed stages and walks back through them. Real systems use feature flags and database migration patterns that allow data shape to evolve without breaking older code.

Try It Yourself

  • Add a "database migration" stage and decide what rolling it back should do.
  • Implement a canary mode: deploy to one server, smoke test, then roll out the rest.
  • Wrap deploy in a retry that tries again once if the smoke test was flaky.

Code Playground

Edit the code below and click Run to see the output. Switch between languages using the tabs.

Loading editor...

Enjoying the lesson? Unlock the full Capstone Project from $4.99/mo.

See plans →