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 unit and integration tests #67

Merged
merged 14 commits into from
May 19, 2023
Merged

Add unit and integration tests #67

merged 14 commits into from
May 19, 2023

Conversation

g-elwell
Copy link
Member

@g-elwell g-elwell commented Mar 12, 2023

This PR adds unit and integration tests using Jest.

Description

I've been playing around with this for a little while as a way of getting to grips with Jest, and feel like I've finally gotten to a point where it's worth sharing and discussing.

The solution I've landed on seems to work well. I've created some tests in the utils directory for each function in there, as well as a larger integration test in the root which is able to run various commands from the CLI and adjusts the mocked filesystem to emulate different outcomes.

To be perfectly honest I didn't realise there were tests running during CI already until I came to write this PR, but it feels like there's some value in this approach so hopefully it's beneficial.

Change log

  • Adds unit and integration tests
  • Adds jest and mock-fs as dev dependencies
  • Adds npm script to run tests
  • Updates use of package variable name to pkg to avoid issue with package being a reserved keyword which was flagged in Jest - docs

Sample test output

image

@g-elwell g-elwell marked this pull request as ready for review March 12, 2023 17:05
@g-elwell g-elwell marked this pull request as draft March 12, 2023 17:06
@g-elwell g-elwell marked this pull request as ready for review March 12, 2023 17:07
@g-elwell
Copy link
Member Author

@ampersarnie do you have any objections or thoughts about these tests?

@ampersarnie
Copy link
Member

@g-elwell Tests look great. Just have a few things which would be nice to have added relating to these;

  1. An additional test script in package.json to run all tests once, and...
  2. Have the tests running in the CI.

If you can add these as well, I'd be glad to approve them.

Copy link
Member

@ampersarnie ampersarnie left a comment

Choose a reason for hiding this comment

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

Approving and addressing run command and ci seperately.

@ampersarnie ampersarnie merged commit 11fe465 into main May 19, 2023
@ampersarnie ampersarnie added the enhancement New feature or request label Jul 17, 2023
@ampersarnie ampersarnie mentioned this pull request Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants