Skip to content

Introduction to Node.js testing using jest and supertest

Notifications You must be signed in to change notification settings

devshafi/intro-nodejs-testing

Repository files navigation

🧪🧪 Intro to unit testing and API testing using javascript and nodejs 🧪🧪

Why testing

  • Reducing bug in production
  • Gain confidence in product
  • Can be used as documentation

Type of testing

type of testing image credit JavaScript testing best practice

We will know three types of testing

  • ✅ Unit testing
  • ✅ API testing (kind of integration testing)
  • ☑️ End to end testing (e2e)

The testing pyramid

type of testing

image credit https://www.headspin.io/

What we are using

  • Jest as test runner and assertion library.

    • Has both test runner (e.g. mocha) and assertion library (e.g. chai) integrated
    • We Need to familiar with matcher functions
  • Supertest for testing node.js HTTP server