-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Improve and Add Comprehensive Test Coverage [#71] #86
base: main
Are you sure you want to change the base?
Conversation
That sounds awesome, can't wait to test it out 🚀 I'll review / try it later because I'm short on time right now, but at first glance I like it very much. Thanks 🙌 |
Hi @Paul-Taiwo. I reviewed your PR right now, and I noticed you moved a significant chunk of code from the server to utils. Why? Could you please revert that change? This would break lots of code out there. It would be ideal if this PR focuses solely on the test suite, not affecting the code itself. |
tsconfig.json
Outdated
@@ -15,7 +15,8 @@ | |||
|
|||
}, | |||
"include": [ | |||
"./src/**/*.ts" | |||
"./src/**/*.ts", | |||
"global.d.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think the "global.d.ts" should be moved to the test dir, or jest dir, and named "mocks" or so, to indicate clearly that it's a file for testing. Does it also have any impact on the production build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points! The global.d.ts
file is purely for typing the global mock variables. Regarding the production build, the declaration file don’t actually emit any JavaScript or impact runtime code, so they won’t alter the production bundle. Still, I've moved it into the jest_config file to keep things tidy and avoid confusion.
The reason for splitting the functions out of the server.ts file is jest can’t mock same-file function calls by default. That means if verifyAuthentication() and verifySignature() (for example) both live in server.ts, any test that tries to mock verifySignature() will still end up calling the real function instead of the mock, because the file references it directly in-memory. I’ll take another look to see if I can find an approach that won’t break the existing code. |
Upon further inspection, there is really a lot that is mocked and real payloads not tested at all. In the end, it tests very little and the coverage is quite misleading. |
okay, I will review the test again. |
This PR addresses the issue [#71]. Key changes include: