Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Unit Tests for CodeBadge #18

Open
shivamluthra opened this issue Nov 20, 2019 · 3 comments
Open

Write Unit Tests for CodeBadge #18

shivamluthra opened this issue Nov 20, 2019 · 3 comments
Labels
gci QA Quality Analysis/Testing

Comments

@shivamluthra
Copy link
Collaborator

shivamluthra commented Nov 20, 2019

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

  • Any Unit testing framework for JavaScript - Beginner/Intermediate level

Steps to Follow

  • Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!
  • Install CodeBadge on your system go through readme.md in development branch for this purpose
  • After installing CodeBadge install dependencies of backend and frontend, go through readme.md inside both the folders
    Link to readme https://github.com/codeuino/Codebadge/blob/master/README.md
  • To run the project follow the given step in readme.md for both frontend and backend.
  • Checkout to a different feature branch in git and start with the coding part.
  • Make sure to commit your work daily and create a single PR for all your commits, per feature.

Acceptance Criteria

  • Code is short, clean and properly indented.
  • Unused code/comments/variables should not be lying in the code unnecessarily exploiting memory.
  • Minimal number of re-iterations in order to improve efficiency and keep the commit history clean.
  • Best practices should be used in case of multiple approaches, mentors are always there to help you for this 👍

Rejection Criteria

  • Not following/Violating Code of Conduct can lead to rejection.
  • Coding etiquettes must be taken care of, for eg, always committing code in a different feature branch, same PR is edited in case of re-iteration of code, etc.

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?

  • Share the issues you encounter along the way and help others solve theirs.
  • Chime in below in a comment to cooperate with others who are also working on this task.
  • Report back at the above issue once you succeed, to encourage others and share what worked for you!

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.

@shivamluthra shivamluthra added gci QA Quality Analysis/Testing labels Nov 20, 2019
@nklayman
Copy link

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

@Rupeshiya
Copy link
Member

Rupeshiya commented Dec 30, 2019

@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
Copy link
Collaborator Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gci QA Quality Analysis/Testing
Projects
None yet
Development

No branches or pull requests

3 participants