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

Add Jest Framework to Frontend #28

Merged
merged 10 commits into from
Mar 17, 2024
Merged

Add Jest Framework to Frontend #28

merged 10 commits into from
Mar 17, 2024

Conversation

WillCWX
Copy link
Collaborator

@WillCWX WillCWX commented Mar 14, 2024

Pull Request

Description

image

  • Adds Jest framework to test the frontend

  • yarn test for jest suite

  • yarn test:update to update snapshots for large UI changes

  • yarn coverage to generate a coverage report

  • We will go with the structure of src/{folder}/__tests__ for each folder to keep the tests close to their components

    • src/{folder}/{sub_folder}/__tests__ for sub folders that are large
  • Snapshot tests of current pages added

    • Assignment page is stuck on a loading snapshot as I can't await the Promise
  • Github actions added to run test suite and generate coverage report (report not yet placed as a badge%)

  • Deletes some unneeded imports for user page (sry the lint keeps nagging)

Dependencies added to dev:

  • Jest, its typescript modules and environments
  • testing-library/react and testing-library/jest-dom
  • ts-node

Related Issue(s)
#27 , may close after some tests written for components, helpers and utilities

Additional Notes/References

You may need to run yarn upgrade as there are issues with yarn and jest according to this.
I solved this issue in the github actions by adding the fix:
"resolutions": { "wrap-ansi": "7.0.0", "string-width": "4.1.0" }

but any side effects from this is unknown

I'll write a quick cheat sheet for jest on frontend later

There is a console log in dateUtils.ts that is caught in this test lol
image

Copy link
Owner

@tryyang2001 tryyang2001 left a comment

Choose a reason for hiding this comment

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

LGTM, great work. The test code is clear and readable :DD

@WillCWX WillCWX merged commit 0085902 into tryyang2001:master Mar 17, 2024
3 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