📔
Labs API Starter
  • Basic Node API
  • Contributing to this scaffold project
  • examples
    • Example Models
    • Example routes of resources
    • Swagger Setup
  • Testing
Powered by GitBook
On this page

Was this helpful?

Testing

PreviousSwagger Setup

Last updated 3 years ago

Was this helpful?

You will be using jest to write function or endpoint/route unit tests in your application. Please put all of your tests for your code in the __tests__ directory. You should get into the habit of ensuring that you have coverage for your code before submitting a pull request.

Running your tests

Follow these steps when writing tests:

  • cd into the root of this directory

  • npm run test to run your test suite

    • if you're prompted select a to run tests in watch mode. This will re-run your test suite when you save any file in your application.

  • In your terminal you will see a test runner that looks something like this:

  • When you're not actively writing tests its best to close that terminal window so that you don't keep running tests when your files are saved.

Coverage

💡 Code coverage should be a good goal to have and a good starting place. But every application will be different.

  • ​. Strive for solid coverage as we strive to hand you over well-tested code in which we have extreme confidence.

  • To run a coverage report for your application simply run npm run coverage.

  • You should see a print out in your console that looks like this:

    ​

Kent Dodds put it nicely
code coverage
Test screenshot