-
Notifications
You must be signed in to change notification settings - Fork 30
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 tests for utils.ts
#294
Conversation
mohamedsalem401
commented
Sep 2, 2024
•
edited
Loading
edited
- Add configuration for jest testing
- Add unit tests for all functions in the utils.ts file
- One commented test that should be uncommented or replaced
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.
Looks great, can we add into CI?
test/utils.spec.ts
Outdated
}); | ||
}); | ||
|
||
// TODO: Fix this test as we can't mock the process.cwd |
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.
How come we can't mock?
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 couldn't figure out the solution for this issue. I think it's related to the following issue in the Jest GitHub repository:
Jest globals differ from Node globals
Also take a look at:
jestjs/jest#5146
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.
@danstarns
I've changed the test, it's currently using the same logic as the actual function itself, so it should always pass, but at least we are ensuring that the function is correctly implemented and accessible in our test environment.
describe('rootResolve', () => {
it('should resolve a relative path to an absolute path', () => {
const result = rootResolve('src/index.js');
expect(result).toBe(path.join(process.cwd(), 'src/index.js'));
});
});
I'll work on that |
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.
🚀