codeuino / codebadge-backend

GNU General Public License v3.0
15 stars 23 forks source link

Write Unit Tests for CodeBadge #18

Open shivamluthra opened 4 years ago

shivamluthra commented 4 years ago

What you will need to know?

Any Unit testing framework for JavaScript - Beginner/Intermediate level

Write Unit Tests for CodeBadge

We can never be doubly sure of our code without automating the unit tests which check the sanity of the code. Although, BDD shall be the preferred coding approach, here we'll have to follow TDD approach. Thus, you'll have to write unit tests for each function used inside every .js file. For this, although you can use any famous Unit Testing framework for JavaScript, but recommended framework is Mocha, along with Chai as it's assertion library. The sanity checks and testing logic shall b well taken care of since passing of unit tests will only decise, whether or not code is to be merged into master. All tests shall pass and code coverage should be >=80%. The test coverage report can be generated using Istanbul library.

Requirements

Steps to Follow

Acceptance Criteria

Rejection Criteria

Expected Outcome

A directory named as /test should be created in the root directory which will include all the .js test files. Each test should be named same as the name of file for which tests are written along with suffixing -spec in the filename. For eg, test file for signup.js should be named as signup-spec.js.

How to excel fast in the community?

Resources & References (Where to Start)

You'll need to go through the docs of Mocha framework, along with Chai as the assertion library to be used. Istanbul can be used for test coverage reporting.

Extras

Just follow the readme whenever you are stuck . Visit Codeuino's Website in case of any doubts.

nklayman commented 4 years ago

Do I have to use mocha or can I use Jest instead? It is officially supported by Vue Test Utils.

Rupeshiya commented 4 years ago

@nklayman For implementing unit test and getting started with, you can look at https://vuejs.org/v2/guide/unit-testing.html

I don't think that there is any issue in using jasmine/jest, it's almost similar to mocha. Please give your view @shivamluthra

shivamluthra commented 4 years ago

@nklayman Hi, sure you can go ahead with Jest as well provided that you have your hands on the same before. Just make sure to use something for assertions as well as I suggested Chai with Mocha in the first place. Good Luck!