The-Enthusiast-404 / git-begin

Git Begin is a Web App to find latest good first issues and start contributing to open source
https://gitbegin.theenthusiast.dev
MIT License
31 stars 18 forks source link

Add Tests for GitHub Service (Jest) #76

Open omjogani opened 2 months ago

omjogani commented 2 months ago

Description

We have a GitHub service, responsible for fetching all good first issues from GitHub, We want to have clean test suits. The testing environment is already configured in the project along with the test file (/__test__/services/github.test.ts).

Usage

to run all the tests run the following command

npm run test

Acceptance Criteria

  1. Mock third-party request calls and return static responses for testing
  2. Add appropriate test name to maintain code readability
  3. Test all functions in the service and refactor the tests frequently whenever required
  4. Consider Edge Cases to cover in the tests
  5. Don't add too many except in single test, rather breakdown those into multiple tests

Engineering Notes

We're using jest for testing and jest-mock-extended for mocking and other pre-made functions.

Feel free to pick this issue and comment down below in case of any questions/feedback!

dotslashbit commented 2 months ago

@omjogani Should we break this in multiple tests per filter?

omjogani commented 2 months ago

@omjogani Should we break this in multiple tests per filter?

Breaking testes into multiple files: Bad Idea while everything resides in github.ts, If we breakdown github.ts file then yes we should breakdown tests too in multiple files.

Breaking functionality into multiple test (filter wise or what so ever): Yes we should do that

dotslashbit commented 2 months ago

@omjogani I think we should break it and then break the tests too, let me know your thoughts?

omjogani commented 2 months ago

@omjogani I think we should break it and then break the tests too, let me know your thoughts?

Well, that's better, I will work on refactoring that by end of this week!

dotslashbit commented 2 months ago

@omjogani Sure, take your time