-
-
Notifications
You must be signed in to change notification settings - Fork 13
feat jest: setup jest environment with jsdom #146
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: main
Are you sure you want to change the base?
feat jest: setup jest environment with jsdom #146
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 environment with jsdom for the Lottie Player project, enabling unit tests for the web component functionality. The setup includes mocking of browser APIs, WASM module handling, and comprehensive test coverage for the LottiePlayer component.
Key changes:
- Added Jest configuration with jsdom environment and Node.js ESM support
- Created comprehensive test mocks for browser APIs (IntersectionObserver, fetch, Canvas APIs)
- Implemented unit tests covering all major LottiePlayer methods and functionality
- Added Node.js-specific build configuration to handle WASM polyfills properly
Reviewed Changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/setup.ts | Test environment setup with mocks for browser APIs and WASM module handling |
tests/lottie-player.test.ts | Comprehensive unit tests for LottiePlayer component methods |
tests/fixtures/base-template.html | HTML template for test DOM setup |
rollup.config.js | Added conditional Node.js build configuration to exclude polyfills |
package.json | Added Jest dependencies and test scripts with ESM support |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
package.json
Outdated
"rollup-plugin-swc3": "^0.10.4", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "*" | ||
"ts-jest": "^29.4.1", |
Copilot
AI
Sep 10, 2025
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.
The ts-jest
dependency appears unused since the Jest configuration uses native Node.js ESM modules with --experimental-vm-modules
flag instead of ts-jest transformation. Consider removing this dependency if it's not being used elsewhere.
"ts-jest": "^29.4.1", |
Copilot uses AI. Check for mistakes.
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.
Thank you. Please check comments
|
||
|
||
(global as any).TextDecoder = TextDecoder; | ||
(global as any).TextEncoder = TextEncoder; |
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.
Don't use any
. If it's only option, please add comment.
package.json
Outdated
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "*" | ||
"ts-jest": "^29.4.1", | ||
"typescript": "^5.9.2" |
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.
No need to change existing dependency.
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.
Sorry, this is my mistake. I'll fix it.
Setting up Jest with jsdom environment and writing unit test code for Lottie Player
changes
tests
and wrote Jest-related code.--experimental-vm-modules
flag. ref.nodePolyfills()
plugin generates polyfills that are not usable in the Node environment, so I added abuild:node
script that can build without it.test
npm run build:node
, please runnpm run test
.