Fix test timeouts in @object-ui/components beforeAll hooks#313
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes test timeout failures in the @object-ui/components package by increasing the beforeAll hook timeout from the default (5-10 seconds) to 30 seconds for tests that import the renderer registry.
Changes:
- Increased
beforeAlltimeout to 30 seconds in 5 test files that load ~80 Radix UI component renderers synchronously - Added explanatory comments documenting the reason for the increased timeout
- Ensures all 156 tests complete successfully in CI environments
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/tests/layout-data-renderers.test.tsx | Added 30s timeout to beforeAll hook importing renderers |
| packages/components/src/tests/form-renderers.test.tsx | Added 30s timeout to beforeAll hook importing renderers |
| packages/components/src/tests/feedback-overlay-renderers.test.tsx | Added 30s timeout to beforeAll hook importing renderers |
| packages/components/src/tests/complex-disclosure-renderers.test.tsx | Added 30s timeout to beforeAll hook importing renderers |
| packages/components/src/tests/basic-renderers.test.tsx | Added 30s timeout to beforeAll hook importing renderers (preventive) |
| beforeAll(async () => { | ||
| await import('../renderers'); | ||
| }); | ||
| }, 30000); // Increase timeout to 30 seconds for heavy renderer imports |
There was a problem hiding this comment.
The 30-second timeout is a pragmatic fix for CI environments, but consider investigating the root cause of slow imports. Loading ~80 renderer components in a beforeAll hook shouldn't take 10+ seconds unless there are:
- Circular dependencies causing multiple re-evaluations
- Heavy synchronous operations during module initialization
- Large dependency trees being loaded
Consider profiling the import with NODE_OPTIONS='--inspect-brk' vitest to identify bottlenecks. If this is purely a CI resource constraint issue, the timeout is reasonable. However, if there's a performance issue in the module loading chain, it should be addressed to improve developer experience in local testing as well.
| beforeAll(async () => { | ||
| await import('../renderers'); | ||
| }); | ||
| }, 30000); // Increase timeout to 30 seconds for heavy renderer imports |
There was a problem hiding this comment.
Consider adding a global testTimeout configuration in vitest.config.mts instead of setting timeouts individually in each test file. This would provide a consistent baseline for all tests and make it easier to adjust if needed:
test: {
globals: true,
testTimeout: 30000, // 30 seconds for heavy imports
hookTimeout: 30000, // Also increase hook timeout
// ... rest of config
}This approach is more maintainable than duplicating the timeout value across multiple test files.
| beforeAll(async () => { | ||
| await import('../renderers'); | ||
| }); | ||
| }, 30000); // Increase timeout to 30 seconds for heavy renderer imports |
There was a problem hiding this comment.
Per coding guideline Rule #2 (Documentation Driven Development), this change should be documented. Consider updating packages/components/src/__tests__/README.md to explain:
- Why the 30-second timeout is needed for
beforeAllhooks that import renderers - The performance implications of loading ~80 renderer components
- Any plans to optimize this in the future
This helps future contributors understand the architecture decision and avoid confusion when seeing the timeout.
Three test files timing out at 10s when importing
../renderersinbeforeAllhooks. The import loads ~50 Radix UI components synchronously.Changes
Increased
beforeAlltimeout to 30s in files importing renderers:Files modified:
feedback-overlay-renderers.test.tsx(was failing)form-renderers.test.tsx(was failing)layout-data-renderers.test.tsx(was failing)basic-renderers.test.tsx(preventive)complex-disclosure-renderers.test.tsx(preventive)All 156 tests now complete within timeout in CI environments.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.