Add Tests, CI and Standard(code quality checks) in NPM package

Words
154
Reading
1 min
Listen
Play
9y

New Features

  • What feature(s) did you add?
    I added tests using ChaiJS and MochaJS.

There are three tests added right now.

  • Moderators Endpoint test
  • Sponsors Endpoint test
  • Posts Endpoint test

Tests log is given below-

$ npm test
> utopian-api@0.4.0 test /home/travis/build/ms10398/utopian-api-npm-1
> standard && mocha --reporter spec
  Utopian Moderator Endpoint test
    ✓ Should return a JSON (129ms)
  Utopian Sponsor Endpoint test
    ✓ Should return a JSON (45ms)
  Utopian Posts Endpoint test
    ✓ Should return a JSON (99ms)
  3 passing (284ms)
The command "npm test" exited with 0.

I have also added Travis CI for auto builds of the npm package with every pull request and commit.
Screenshot from 2018-01-20 09-40-17.png

  • How did you implement it/them?

For Tests you can check my code here.

For Travis I configured to run tests and build using npm install.
travis.yml file conten is -

language : node_js
node_js :
 - stable
install:
 - npm install
script:
 - npm test

Bug Fixes

As the project was growing we have to maintain the code quality of the project. So for that I have added standard a npm package for code quality tests.
While adding there was a huge error log which needed to be fixed I have fixed it.
For lazy people standard helps in easy fixes I have mentioned it in readme.



Posted on Utopian.io - Rewarding Open Source Contributors

Add Tests, CI and Standard(code quality checks) in NPM package | Ecency