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

feat: increase test coverage to api #111

Merged
merged 49 commits into from
Oct 18, 2024
Merged

Conversation

gabrielegranello
Copy link
Collaborator

What does this PR do?

It adds a series of unit tests for the API (route.ts, services, data and repo).

How?

for every file in the API e.g. rentService.ts, there is paired file rentService.test.ts with the unit tests in it. Tests are written in jest.

Any other modification?

I modified the jest.config.ts and changed the environment to node to test some of prisma specific functions. Also, in terms of branches percentage I had to slightly lower it because I wasn't able to reach 100%. If you try and run the test you can see that there is 1 line in bd.ts and one line in calculationService.ts that I am not able to engage with. Happy to hear your thoughts on that :)

Copy link

vercel bot commented Oct 10, 2024

Someone is attempting to deploy this pull request to the Open Systems Lab's projects Team on Vercel.

To accomplish this, the commit author's email address needs to be associated with a GitHub account.

Learn more about how to change the commit author information.

@gabrielegranello
Copy link
Collaborator Author

Oh interesting, I am getting some errors here that I don't see. It has to do with the variable hpi2020, something that we recently changed. Perhaps we can look at it together?

@gabrielegranello gabrielegranello requested a review from a team October 11, 2024 10:11
Copy link

vercel bot commented Oct 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fairhold-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 11, 2024 2:15pm

Copy link

vercel bot commented Oct 11, 2024

@gabrielegranello is attempting to deploy a commit to the Open Systems Lab team on Vercel, but is not a member of this team. To resolve this issue, you can:

  • Make your repository public. Collaboration is free for open source and public repositories.
  • Add @gabrielegranello as a member. A Pro subscription is required to access Vercel's collaborative features.
    • If you're the owner of the team, click here and add @gabrielegranello as a member.
    • If you're the user who initiated this build request, click here to request access.
    • If you're already a member of the Open Systems Lab team, make sure that your Vercel account is connected to your GitHub account.

To read more about collaboration on Vercel, click here.

@gabrielegranello gabrielegranello changed the title Gg/test api coverage feat: increase test coverage to api Oct 11, 2024
Copy link
Collaborator

@zz-hh-aa zz-hh-aa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gabrielegranello, ran the tests locally and they look good to me!

I tried to generate the coverage report to investigate the <100% coverage but didn't have any luck--am I missing something? This is what happened after I ran npm run test:coverage:

> [email protected] test:coverage
> jest; open ./coverage/lcov-report/index.html

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\zzhha\Dropbox\PC\Desktop\working\jobs\osl\Fairhold_calc\fairhold-dashboard
  153 files checked.
  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 29 matches
  testPathIgnorePatterns: \\node_modules\\ - 153 matches
  testRegex:  - 0 matches
Pattern: ;|open|.\\coverage\\lcov-report\\index.html - 0 matches

@gabrielegranello
Copy link
Collaborator Author

gabrielegranello commented Oct 18, 2024

Oh bizarre @zz-hh-aa , if I do run npm test:coverage I get the screenshot below
Screenshot 2024-10-18 at 09 39 43

I am not really sure what's going on. You can successfully run the tests right? But if you specify run npm test:coverage, then you get an error message saying no test found?

@gabrielegranello gabrielegranello merged commit 1bfcad8 into main Oct 18, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants