feat(esm): packages/vite api side vitest support#359
Conversation
✅ Deploy Preview for cedarjs canceled.
|
There was a problem hiding this comment.
Greptile Summary
This PR adds API-side Vitest testing support to the CedarJS framework by creating a new testing preset configuration. The changes introduce a new export path './api' in the @cedarjs/vite package that provides a bundled Vitest configuration specifically tailored for API testing scenarios.
The implementation follows CedarJS's preset pattern by creating cedarVitestPreset function that combines four essential Vite plugins: cedarVitestApiConfigPlugin for environment setup and test configuration, autoImportsPlugin for automatic importing of testing utilities like mockContext, mockHttpEvent, gql, and context, cedarjsDirectoryNamedImportPlugin to maintain compatibility with CedarJS's directory-based import conventions, and trackDbImportsPlugin for database interaction tracking during tests.
The package.json modifications add the new export entry pointing to the compiled TypeScript output and include @cedarjs/testing as a workspace dependency. The preset file uses ESM-compatible imports with .js extensions, aligning with the broader ESM preparation work indicated in the branch name. This mirrors the existing web-side testing architecture, providing consistency across the framework's testing infrastructure and making it easier for developers to configure API-side tests with a single preset rather than manually configuring multiple plugins.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it adds new functionality without modifying existing code
- Score reflects clean implementation following established patterns and straightforward plugin bundling approach
- Pay close attention to the new export path in package.json to ensure proper module resolution
2 files reviewed, 1 comment
Bringing over the last
packages/vitechanges from #80 to themainbranchPR (6/n) for adding ESM support. See #349 for PR 1/n in the series