My Integration Testing Checklist (JavaScript)

  • Mocha as test runner on the back-end; while I’ve used Karma on the front-end with Angular
  • ChaiJS as assertion library; Jasmine is also a wonderful solution that I’ve used on the front-end
  • SinonJS for spying, stubbing and mocking classes, objects and functions
  • Moxios for mocking API requests done using Axios
  • Proxyquire for stubbing dependencies
  • FakerJS for generating random fake data

Checklist:

  • [ ] Require modules
  • [ ] Main describe block
  • [ ] Top level before and After block
  • [ ] Describe block for every (public) function for the file
  • [ ] It statement for the main flow for most code coverage
  • [ ] Write expect or assert based on the function return value (test should fail at first)
  • [ ] Write minimum code to make test succeed (with most coverage flow if not difficult)
  • [ ] Stub dependent functions in the same file or another file to unit test this function
  • [ ] Pass enough test for 75% to 80% code coverage

Notes

To keep the testing files short and simple, I usually write a separate file for a service or api file. For example, login.service.ts has a file in the test folder with a similar name.

--

--

Senior Software Developer, Writer, Amateur Photographer, Reader

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abdallah Yashir

Abdallah Yashir

Senior Software Developer, Writer, Amateur Photographer, Reader