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 test to mainAsync #151

Merged
merged 5 commits into from
May 1, 2024
Merged

Add unit test to mainAsync #151

merged 5 commits into from
May 1, 2024

Conversation

armanio123
Copy link
Member

Adds a simple unit test for the mainAsync function.

Mostly mocks the dependencies on the file system and utility modules. This allows to easily test the mainAsync with a snapshot during local development.

Please note that I was not able to accurately verify that this is the expected result. I appreciate if any reviewer put special emphasis on the accuracy of the output.

@jakebailey
Copy link
Member

Seems like the tests fail; you're mocking the FS but also using the FS.

@armanio123
Copy link
Member Author

Fixed. I didn't occur to me to run the rest of the tests, I think it will work now.

@armanio123
Copy link
Member Author

armanio123 commented Apr 30, 2024

Seems like I was wrong. path is showing as undefined but I don't understand why. I'm not mocking path.

Comment on lines +16 to +17
// @ts-ignore
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
Copy link
Member

Choose a reason for hiding this comment

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

What version of node are you on? This should be present.

Copy link
Member Author

Choose a reason for hiding this comment

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

v20.12.1

Copy link
Member

Choose a reason for hiding this comment

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

Hm, was this crashing locally or in CI?

image

(It passed for me previously when I introduced this code, anyway....)

Copy link
Member Author

Choose a reason for hiding this comment

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

Locally, I assume it would crash on CI but I can give it a try without it

Copy link
Member

Choose a reason for hiding this comment

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

Wow, it does fail. That doesn't make any sense at all...

Copy link
Member Author

Choose a reason for hiding this comment

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

It fails on CI as well

Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is because jest makes an entirely different environment that's missing these, even though the system has it: jestjs/jest#14874

I guess we can leave it in, though we could probably also just swap jest out for vitest.

Copy link
Member Author

Choose a reason for hiding this comment

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

I put it back then. We can track migrating to vitest on issue #153

@armanio123 armanio123 merged commit c54c664 into main May 1, 2024
2 checks passed
@armanio123 armanio123 deleted the AddMainUnitTest branch May 1, 2024 21:29
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