-
-
Notifications
You must be signed in to change notification settings - Fork 235
[WIP]: unit test for custom hooks #1027
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
base: develop
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
Pull Request Overview
This PR sets up Jest testing for the @keyshade/platform
app and adds comprehensive unit tests for the useIsAppleDevice
hook.
- Configure Jest with
ts-jest
, a customjest.config.ts
, and module name mappings. - Update
tsconfig.json
andpackage.json
in the platform app to include test files and testing dependencies. - Add a new test suite for the
useIsAppleDevice
hook covering various user-agent strings.
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
package.json (root) | Updated test:platform script to run without dependencies. |
apps/platform/tsconfig.json | Included __tests__/**/*.ts and jest.config.ts in compilation. |
apps/platform/package.json | Added type: "module" , testing scripts, and Jest-related deps. |
apps/platform/jest.config.ts | New Jest config using ts-jest , jsdom , and custom mappings. |
apps/platform/tests/hooks/use-is-apple-device.test.ts | New test file covering useIsAppleDevice against various UAs. |
Comments suppressed due to low confidence (1)
apps/platform/tests/hooks/use-is-apple-device.test.ts:33
- [nitpick] The keys in
osAgentPairs
mix casing (e.g.mac
,iPad
,androidTablet
); consider using consistent lowercase naming to avoid confusion.
const osAgentPairs = {
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
coverageDirectory: '../../coverage/apps/workspace' | ||
testMatch: ['**/__tests__/**/*.(spec|test).(ts|tsx)'], |
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.
Consider adding a coverageDirectory
field (e.g. coverage/apps/platform
) so that test coverage reports are consistently generated and stored.
Copilot uses AI. Check for mistakes.
CI Feedback 🧐(Feedback updated until commit 276cfae)A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
@kriptonian1, please resolve all open reviews! |
@kriptonian1, please resolve all open reviews; otherwise this PR will be closed after Sun Jun 29 2025 19:58:27 GMT+0000 (Coordinated Universal Time)! |
User description
Description
Write unit test for custom hooks
Dependencies
Developer's checklist
If changes are made in the code:
Documentation Update
PR Type
Tests
Description
Add comprehensive unit tests for
useIsAppleDevice
hookConfigure Jest testing environment with TypeScript support
Set up testing dependencies and module path mapping
Update package scripts for platform testing
Changes walkthrough 📝
use-is-apple-device.test.ts
Add comprehensive useIsAppleDevice hook tests
apps/platform/tests/hooks/use-is-apple-device.test.ts
useIsAppleDevice
hookjest.config.ts
Configure Jest testing environment
apps/platform/jest.config.ts
@/
and@public/
pathspackage.json
Update platform test command
package.json
--no-deps
flagtsconfig.json
Include test files in TypeScript config
apps/platform/tsconfig.json
__tests__/**/*.ts
andjest.config.ts
to include arraypackage.json
Add testing dependencies and scripts
apps/platform/package.json