-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test(create-egg): add test for simple-ts template #5538
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
Conversation
…ions
- Add vitest configuration and setup files for simple-ts template
- Update test assertions to match actual output ("hi, egg, TypeScript")
- Add integration test for simple-ts template scaffolding
- Verify generated project can run tests successfully with pnpm link
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds Vitest setup/config and updates test expectations in templates; introduces simple-ts scaffolding tests to the create-egg CLI tests; converts several runtime imports to type-only imports; adds "type": "module" to multiple template package.json files; simplifies tegg template config exports to typed object literals; adjusts tsconfig and root package.json ordering; fixes async test cleanup and increases Vitest timeout; expands CLAUDE.md documentation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer/CI
participant CLI as create-egg CLI
participant FS as Filesystem (scaffolded project)
participant PNPM as pnpm
participant VT as Vitest
participant App as Scaffolded App
Dev->>CLI: run create-egg --template simple-ts
CLI->>FS: scaffold files (includes vitest.config.ts, test/setup.ts)
Dev->>PNPM: link local packages into scaffold
PNPM-->>Dev: packages linked
Dev->>VT: run tests in scaffolded app
VT->>App: load vitest.config.ts -> execute test/setup.ts (expose hooks)
VT->>App: run tests
App-->>VT: test responses "hi, egg, TypeScript"
VT-->>Dev: report tests passed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @fengmk2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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 adds comprehensive testing support for the simple-ts template in the create-egg tool and fixes test assertions to match the actual output. The changes ensure that the simple-ts template can be properly scaffolded and tested.
Key changes:
- Added vitest configuration and test setup files for the simple-ts template
- Updated test assertions to expect "hi, egg, TypeScript" instead of "hi, egg"
- Added integration test that verifies the generated simple-ts project can run tests successfully
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/create-egg/test/cli.test.ts | Added integration test for simple-ts template scaffolding and fixed package.json creation |
| tools/create-egg/test/snapshots/cli.test.ts.snap | Added snapshot for simple-ts template file structure |
| tools/create-egg/src/templates/simple-ts/vitest.config.ts | Added vitest configuration for simple-ts template |
| tools/create-egg/src/templates/simple-ts/test/setup.ts | Added vitest setup file with global test hooks |
| tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts | Updated assertion to match actual service output |
| tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts | Updated assertion to match actual controller output |
| package.json | Minor alphabetical reordering of dependencies |
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.
Code Review
This pull request adds a comprehensive integration test for the simple-ts template, ensuring that the generated project is correctly scaffolded and its tests pass. The changes include adding necessary vitest configurations, updating test assertions to match the template's output, and creating a new test case that simulates the user workflow.
My review focuses on improving the robustness and maintainability of the new test code. I've suggested ensuring proper cleanup of temporary directories in the integration test to prevent side effects, and a more type-safe way of extending globalThis in the test setup file, avoiding the use of @ts-expect-error.
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tools/create-egg/src/templates/simple-ts/test/setup.ts (1)
6-9: Prefer declaring the globals instead of suppressing TypeScript.Rather than leaning on
@ts-expect-error, we can extend the global typings so the assignments stay type-safe and future-proof.-// @ts-expect-error globalThis is not typed -globalThis.beforeAll = beforeAll; -// @ts-expect-error globalThis is not typed -globalThis.afterAll = afterAll; +declare global { + var beforeAll: typeof beforeAll; + var afterAll: typeof afterAll; +} + +globalThis.beforeAll = beforeAll; +globalThis.afterAll = afterAll;tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts (1)
5-9: Align the test description with the new assertion.The body now checks for “hi, egg, TypeScript” but the description still mentions the old phrase. Renaming the test keeps intent clear.
- test('sayHi should return hi, egg', async () => { + test('sayHi should return hi, egg, TypeScript', async () => {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tools/create-egg/test/__snapshots__/cli.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
package.json(1 hunks)tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts(1 hunks)tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts(1 hunks)tools/create-egg/src/templates/simple-ts/test/setup.ts(1 hunks)tools/create-egg/src/templates/simple-ts/vitest.config.ts(1 hunks)tools/create-egg/test/cli.test.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
Files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/test/app/controller/home.test.tstools/create-egg/src/templates/simple-ts/vitest.config.tstools/create-egg/src/templates/simple-ts/test/app/service/Test.test.tstools/create-egg/test/cli.test.ts
**/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites
Files:
tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.tstools/create-egg/src/templates/simple-ts/test/app/service/Test.test.tstools/create-egg/test/cli.test.ts
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/test/app/controller/home.test.tstools/create-egg/src/templates/simple-ts/test/app/service/Test.test.tstools/create-egg/test/cli.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Mirror the repository test pattern when adding new suites
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/test/cli.test.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Applied to files:
tools/create-egg/src/templates/simple-ts/test/setup.tstools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: For features affecting HTTP or process orchestration, add regression tests that exercise both the CommonJS and TypeScript example apps
Applied to files:
tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation
Applied to files:
tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to pnpm-workspace.yaml : Define dependency versions via the catalog section in pnpm-workspace.yaml and reference them with "catalog:"
Applied to files:
package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins,tools}/**/package.json : Individual packages must reference external dependencies via "catalog:" from pnpm-workspace.yaml
Applied to files:
package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to pnpm-workspace.yaml : Define external dependency versions centrally in the catalog section of pnpm-workspace.yaml
Applied to files:
package.json
🧬 Code graph analysis (1)
tools/create-egg/src/templates/simple-ts/vitest.config.ts (1)
packages/egg/src/lib/types.ts (1)
defineConfig(120-122)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Test egg-bin (windows-latest, 24)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test packages (windows-latest, 22)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Test packages (macos-latest, 24)
- GitHub Check: Test packages (macos-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Test packages (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: Test packages (windows-latest, 24)
- GitHub Check: Test packages (ubuntu-latest, 22)
🔇 Additional comments (3)
package.json (1)
26-27: Reorderingsemverkeeps the catalog references tidy.No functional impact here and the catalog contract remains intact.
tools/create-egg/src/templates/simple-ts/vitest.config.ts (1)
1-7: Thanks for wiring the Vitest setup file.This keeps the template self-contained and ensures the bootstrap globals come online before the suites run.
tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts (1)
5-8: Expectation update matches the generated greeting.The assertion now reflects the template output—looks good.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #5538 +/- ##
==========================================
+ Coverage 75.84% 75.89% +0.05%
==========================================
Files 114 114
Lines 5770 5770
Branches 1151 1152 +1
==========================================
+ Hits 4376 4379 +3
+ Misses 1214 1211 -3
Partials 180 180 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tools/create-egg/src/templates/tegg/app/module/bar/package.json (1)
1-7: Mark all tegg module packages as private
Add"private": trueafter the"name"field in each module’s package.json under tools/create-egg/src/templates/tegg/app/module to prevent accidental publishes. For example:tools/create-egg/src/templates/tegg/app/module/<module>/package.json { "name": "<module>", + "private": true, "eggModule": { "name": "<module>" }, "type": "module" }
🧹 Nitpick comments (7)
tools/create-egg/vitest.config.ts (1)
5-5: Consider raising timeout or confirm CI stability20s might be tight for scaffold/integration steps. If you’ve seen flakiness, bump to 30–60s.
Apply this diff if needed:
- testTimeout: 20000, + testTimeout: 30000,tools/create-egg/src/templates/tegg/package.json (1)
25-35: Confirm intentional use of "beta" tagsUsing dist‑tag "beta" for core deps (egg, tegg, vitest) can introduce breaking changes over time in generated apps. If stability is preferred, consider pinning specific pre‑releases.
Also applies to: 37-46
tools/create-egg/src/templates/tegg/test/setup.ts (1)
1-9: Type the globals instead of suppressing errorsAvoid ts‑expect‑error by declaring globals; also consider exposing beforeEach/afterEach for parity.
Apply:
-import { beforeAll, afterAll } from 'vitest'; +import { beforeAll, afterAll, beforeEach, afterEach } from 'vitest'; // https://vitest.dev/config/#setupfiles // export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it -// @ts-expect-error globalThis is not typed -globalThis.beforeAll = beforeAll; -// @ts-expect-error globalThis is not typed -globalThis.afterAll = afterAll; +declare global { + // eslint-disable-next-line no-var + var beforeAll: typeof beforeAll; + // eslint-disable-next-line no-var + var afterAll: typeof afterAll; + // eslint-disable-next-line no-var + var beforeEach: typeof beforeEach; + // eslint-disable-next-line no-var + var afterEach: typeof afterEach; +} + +globalThis.beforeAll = beforeAll; +globalThis.afterAll = afterAll; +globalThis.beforeEach = beforeEach; +globalThis.afterEach = afterEach;tools/create-egg/src/templates/tegg/config/config.prod.ts (1)
3-5: Usesatisfies PartialEggConfiginstead of anascastKeeps strict typing without widening.
Apply:
export default { // add your config here -} as PartialEggConfig; +} satisfies PartialEggConfig;tools/create-egg/src/templates/tegg/config/config.unittest.ts (1)
3-5: Switch tosatisfies PartialEggConfigfor safer typingConsistent with other config files and keeps literal types intact.
Apply:
export default { // add your config here -} as PartialEggConfig; +} satisfies PartialEggConfig;tools/create-egg/src/templates/tegg/config/config.local.ts (1)
3-5: Replaceas PartialEggConfigwithsatisfies PartialEggConfigin all tegg config templates
- tools/create-egg/src/templates/tegg/config/config.local.ts
- tools/create-egg/src/templates/tegg/config/config.unittest.ts
- tools/create-egg/src/templates/tegg/config/config.prod.ts
- tools/create-egg/src/templates/tegg/config/config.default.ts
tools/create-egg/src/templates/tegg/config/config.default.ts (1)
1-1: AnnotateappInfoand usesatisfiesfor safer typings
- Import
EggAppInfoand annotate the callback:import { defineConfig, type EggAppInfo, type PartialEggConfig } from 'egg'; export default defineConfig((appInfo: EggAppInfo) => ({ … } satisfies PartialEggConfig));- Update any example references to the
eggjs/examplesrepo to use its defaultmasterbranch.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tools/create-egg/test/__snapshots__/cli.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (17)
tools/create-egg/src/templates/tegg/app/module/bar/controller/home.ts(1 hunks)tools/create-egg/src/templates/tegg/app/module/bar/controller/user.ts(1 hunks)tools/create-egg/src/templates/tegg/app/module/bar/package.json(1 hunks)tools/create-egg/src/templates/tegg/app/module/foo/package.json(1 hunks)tools/create-egg/src/templates/tegg/app/module/foo/service/HelloService.ts(1 hunks)tools/create-egg/src/templates/tegg/config/config.default.ts(2 hunks)tools/create-egg/src/templates/tegg/config/config.local.ts(1 hunks)tools/create-egg/src/templates/tegg/config/config.prod.ts(1 hunks)tools/create-egg/src/templates/tegg/config/config.unittest.ts(1 hunks)tools/create-egg/src/templates/tegg/config/plugin.ts(1 hunks)tools/create-egg/src/templates/tegg/package.json(2 hunks)tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts(1 hunks)tools/create-egg/src/templates/tegg/test/setup.ts(1 hunks)tools/create-egg/src/templates/tegg/tsconfig.json(0 hunks)tools/create-egg/src/templates/tegg/vitest.config.ts(1 hunks)tools/create-egg/test/cli.test.ts(3 hunks)tools/create-egg/vitest.config.ts(1 hunks)
💤 Files with no reviewable changes (1)
- tools/create-egg/src/templates/tegg/tsconfig.json
✅ Files skipped from review due to trivial changes (1)
- tools/create-egg/src/templates/tegg/app/module/bar/controller/user.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- tools/create-egg/test/cli.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
{packages,plugins,tools}/**/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
{packages,plugins,tools}/**/package.json: Individual packages must reference external dependencies via "catalog:" from pnpm-workspace.yaml
Use "workspace:*" for internal monorepo dependencies between packages
Files:
tools/create-egg/src/templates/tegg/app/module/bar/package.jsontools/create-egg/src/templates/tegg/app/module/foo/package.jsontools/create-egg/src/templates/tegg/package.json
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
Files:
tools/create-egg/src/templates/tegg/config/plugin.tstools/create-egg/src/templates/tegg/config/config.local.tstools/create-egg/src/templates/tegg/config/config.unittest.tstools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.tstools/create-egg/vitest.config.tstools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/vitest.config.tstools/create-egg/src/templates/tegg/app/module/foo/service/HelloService.tstools/create-egg/src/templates/tegg/config/config.prod.tstools/create-egg/src/templates/tegg/config/config.default.tstools/create-egg/src/templates/tegg/app/module/bar/controller/home.ts
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/*/package.json : Plugin package.json must include an eggPlugin configuration field
Applied to files:
tools/create-egg/src/templates/tegg/config/plugin.tstools/create-egg/src/templates/tegg/package.jsontools/create-egg/src/templates/tegg/config/config.default.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode
Applied to files:
tools/create-egg/src/templates/tegg/config/plugin.tstools/create-egg/src/templates/tegg/app/module/foo/package.jsontools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output
Applied to files:
tools/create-egg/src/templates/tegg/config/config.local.tstools/create-egg/src/templates/tegg/config/config.unittest.tstools/create-egg/src/templates/tegg/package.jsontools/create-egg/src/templates/tegg/config/config.prod.tstools/create-egg/src/templates/tegg/config/config.default.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation
Applied to files:
tools/create-egg/src/templates/tegg/config/config.local.tstools/create-egg/src/templates/tegg/package.jsontools/create-egg/src/templates/tegg/config/config.default.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Applied to files:
tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.tstools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Applied to files:
tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.tstools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Applied to files:
tools/create-egg/vitest.config.tstools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Applied to files:
tools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Applied to files:
tools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Applied to files:
tools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Applied to files:
tools/create-egg/src/templates/tegg/test/setup.tstools/create-egg/src/templates/tegg/vitest.config.ts
🧬 Code graph analysis (5)
tools/create-egg/src/templates/tegg/config/config.local.ts (1)
packages/egg/src/lib/types.ts (1)
PartialEggConfig(97-97)
tools/create-egg/src/templates/tegg/config/config.unittest.ts (1)
packages/egg/src/lib/types.ts (1)
PartialEggConfig(97-97)
tools/create-egg/src/templates/tegg/vitest.config.ts (1)
packages/egg/src/lib/types.ts (1)
defineConfig(120-122)
tools/create-egg/src/templates/tegg/config/config.prod.ts (1)
packages/egg/src/lib/types.ts (1)
PartialEggConfig(97-97)
tools/create-egg/src/templates/tegg/config/config.default.ts (1)
packages/egg/src/lib/types.ts (2)
defineConfig(120-122)PartialEggConfig(97-97)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Socket Security: Pull Request Alerts
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Test packages (macos-latest, 22)
- GitHub Check: Test packages (windows-latest, 22)
- GitHub Check: Test packages (macos-latest, 24)
- GitHub Check: Test packages (ubuntu-latest, 24)
- GitHub Check: Test packages (windows-latest, 24)
- GitHub Check: Test packages (ubuntu-latest, 22)
🔇 Additional comments (6)
tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts (1)
4-4: Import resolves correctly to module entrypoint.The relative path now targets the module’s re-export surface, matching the updated template layout.
tools/create-egg/src/templates/tegg/app/module/foo/service/HelloService.ts (1)
1-1: Type‑only import LGTMSwitching EggLogger to a type import avoids unnecessary runtime deps.
tools/create-egg/src/templates/tegg/config/plugin.ts (1)
1-34: Type‑only EggPlugin import LGTMConfig object looks correct and export is ESM‑friendly.
tools/create-egg/src/templates/tegg/app/module/foo/package.json (1)
5-6: Module type addition LGTM"Type": "module" aligns with the template’s ESM direction.
tools/create-egg/src/templates/tegg/app/module/bar/controller/home.ts (1)
1-19: Type‑only import LGTMPattern matches other files; no runtime import of types.
tools/create-egg/src/templates/tegg/vitest.config.ts (1)
1-7: Vitest setup config LGTMSetup file wiring is correct and minimal.
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
CLAUDE.md (1)
225-231: Fix the Markdown emphasis formatting.
The escaped asterisks leak into the rendered text. Tightening the emphasis keeps the guideline readable.-- **`entry: 'src/**/\*.ts'`\*\* - Processes all TypeScript files in src directory +- **`entry: 'src/**/*.ts'`** - Processes all TypeScript files in the src directory
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
CLAUDE.md(2 hunks)tools/create-egg/src/templates/simple-ts/test/setup.ts(1 hunks)tools/create-egg/src/templates/tegg/package.json(2 hunks)tools/create-egg/src/templates/tegg/test/setup.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- tools/create-egg/src/templates/tegg/test/setup.ts
- tools/create-egg/src/templates/simple-ts/test/setup.ts
🧰 Additional context used
📓 Path-based instructions (1)
{packages,plugins,tools}/**/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
{packages,plugins,tools}/**/package.json: Individual packages must reference external dependencies via "catalog:" from pnpm-workspace.yaml
Use "workspace:*" for internal monorepo dependencies between packages
Files:
tools/create-egg/src/templates/tegg/package.json
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Applied to files:
CLAUDE.md
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode
Applied to files:
CLAUDE.mdtools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Applied to files:
CLAUDE.md
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Applied to files:
CLAUDE.md
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Applied to files:
CLAUDE.md
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Applied to files:
CLAUDE.mdtools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/*/package.json : Plugin package.json must include an eggPlugin configuration field
Applied to files:
tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation
Applied to files:
tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output
Applied to files:
tools/create-egg/src/templates/tegg/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Test packages (ubuntu-latest, 24)
- GitHub Check: Test packages (macos-latest, 24)
- GitHub Check: Test packages (macos-latest, 22)
- GitHub Check: Test packages (windows-latest, 24)
- GitHub Check: Test packages (ubuntu-latest, 22)
- GitHub Check: Test packages (windows-latest, 22)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 24)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Cloudflare Pages: egg-v3
🔇 Additional comments (1)
tools/create-egg/src/templates/tegg/package.json (1)
13-13: Fix NODE_OPTIONS quoting for Windows compatibilitySingle-quoting the value leaves literal
'characters in the environment on Windows, so Node sees\'--importand exits with an unknown option error. Drop the quotes and use=to avoid spaces.Apply this diff:
- "test:local": "cross-env NODE_OPTIONS='--import @oxc-node/core/register' vitest run", + "test:local": "cross-env NODE_OPTIONS=--import=@oxc-node/core/register vitest run",
|
Review the following changes in direct dependencies. Learn more about Socket 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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
tools/create-egg/test/cli.test.ts (4)
15-16: Correct mkdtemp usage; optional: initialize tempDir in beforeAll to avoid module-level side effectsCreating the temp dir at import time can have side effects with filtered/partial runs. Initialize it in beforeAll instead.
Apply this diff:
-const tempDirPrefix = path.join(tmpdir(), 'my-app-temp-'); -const tempDir = fs.mkdtempSync(tempDirPrefix); +const tempDirPrefix = path.join(tmpdir(), 'create-egg-'); +let tempDir: string;And update hooks:
// inside this file beforeAll(() => { tempDir = fs.mkdtempSync(tempDirPrefix); }); afterAll(() => { if (tempDir) fs.rmSync(tempDir, { recursive: true, force: true }); });
30-30: Prefer JSON.stringify for package.jsonAvoid raw string JSON. Safer and clearer.
- fs.writeFileSync(pkgJson, '{ "foo": "bar", "type": "module" }'); + fs.writeFileSync(pkgJson, JSON.stringify({ foo: 'bar', type: 'module' }, null, 2));
130-152: Reduce duplication and apply the same robustness to tegg test
- This duplicates the earlier tegg scaffolding test; consider parameterizing templates to DRY.
- Apply the same safer linking approach here.
Apply this diff to split linking:
- execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link ${mockDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link ${eggDir}`, { cwd: projectDir });
109-129: Harden simple-ts integration test: safer linking and resilience
- Split linking into two commands:
- execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link ${mockDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link ${eggDir}`, { cwd: projectDir });
- Wrap test steps in
try/finallyto cleanupprojectDiron failure.- Optionally invoke
pnpm test:local -- --reporter=jsonand parse the JSON reporter instead of matching'2 passed'.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tools/create-egg/src/templates/tegg/package.json(2 hunks)tools/create-egg/test/cli.test.ts(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- tools/create-egg/src/templates/tegg/package.json
🧰 Additional context used
📓 Path-based instructions (2)
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
Files:
tools/create-egg/test/cli.test.ts
**/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites
Files:
tools/create-egg/test/cli.test.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: For features affecting HTTP or process orchestration, add regression tests that exercise both the CommonJS and TypeScript example apps
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Applied to files:
tools/create-egg/test/cli.test.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Mirror the repository test pattern when adding new suites
Applied to files:
tools/create-egg/test/cli.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (windows-latest, 24)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Test packages (windows-latest, 22)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Test packages (windows-latest, 24)
- GitHub Check: Test packages (macos-latest, 24)
- GitHub Check: Test packages (ubuntu-latest, 22)
- GitHub Check: Test packages (ubuntu-latest, 24)
- GitHub Check: Test packages (macos-latest, 22)
🔇 Additional comments (3)
tools/create-egg/test/cli.test.ts (3)
3-3: Good fix: using tmpdir for mkdtemp prefixThis addresses the earlier mkdtemp prefix issue.
7-7: Vitest lifecycle imports look goodImports align with usage in this file.
50-50: Cleanup hook is appropriateRemoving the temp workspace in afterAll is correct.
| "stop": "eggctl stop --title=egg-server-{{name}}", | ||
| "dev": "egg-bin dev", | ||
| "test:local": "vitest run", | ||
| "test:local": "cross-env NODE_OPTIONS=\"--import @oxc-node/core/register\" vitest run", |
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.
should auto import @oxc-node/core/register when tegg plugin load
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tools/create-egg/test/cli.test.ts (2)
127-128: Link packages individually; avoid multi-arg pnpm link and quote paths
pnpm linkmay not accept multiple paths reliably; quoting also avoids issues with spaces.Apply this diff:
- execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir });And similarly in the tegg test:
- execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir });Also applies to: 151-153
30-31: Confirm need for "type": "module" in the non-empty-dir sentinelIf this file is used purely to mark the directory as non-empty, consider minimizing contents to reduce any unintended CLI branching based on package type.
Example minimal content:
{ "name": "non-empty" }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tools/create-egg/test/cli.test.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
Files:
tools/create-egg/test/cli.test.ts
**/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites
Files:
tools/create-egg/test/cli.test.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Applied to files:
tools/create-egg/test/cli.test.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Mirror the repository test pattern when adding new suites
Applied to files:
tools/create-egg/test/cli.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Test egg-bin (macos-latest, 24)
- GitHub Check: Test egg-bin (ubuntu-latest, 24)
- GitHub Check: Test egg-bin (windows-latest, 22)
- GitHub Check: Test egg-bin (macos-latest, 22)
- GitHub Check: Test egg-bin (ubuntu-latest, 22)
- GitHub Check: Test egg-bin (windows-latest, 24)
- GitHub Check: Test packages (ubuntu-latest, 24)
- GitHub Check: Test packages (windows-latest, 24)
- GitHub Check: Test packages (ubuntu-latest, 22)
- GitHub Check: Test packages (macos-latest, 24)
- GitHub Check: Test packages (windows-latest, 22)
- GitHub Check: Test packages (macos-latest, 22)
🔇 Additional comments (2)
tools/create-egg/test/cli.test.ts (2)
109-131: Prefer per-test temp dirs with try/finally to ensure cleanup on failuresCreating a shared temp dir at module scope can leak if the process crashes mid-test. Create a temp dir inside each integration test and clean it with try/finally.
Apply this diff to the simple-ts test:
test.skipIf(process.platform === 'win32')( 'successfully scaffolds a project based on simple-ts starter template', - () => { - const projectName = 'create-egg-test-simple-ts'; - const { stdout } = run([projectName, '--template', 'simple-ts'], { - cwd: tempDir, - }); - const projectDir = path.join(tempDir, projectName); - const generatedFiles = fs.readdirSync(projectDir).sort(); + () => { + const prefix = path.join(tmpdir(), 'create-egg-'); + const localTemp = fs.mkdtempSync(prefix); + try { + const projectName = 'create-egg-test-simple-ts'; + const { stdout } = run([projectName, '--template', 'simple-ts'], { + cwd: localTemp, + }); + const projectDir = path.join(localTemp, projectName); + const generatedFiles = fs.readdirSync(projectDir).sort(); // Assertions expect(stdout).toContain(`Scaffolding project with`); - expect(generatedFiles).matchSnapshot(); + expect(generatedFiles).toMatchSnapshot(); // run test const monoRepoDir = path.join(import.meta.dirname, '../../../'); const eggDir = path.join(monoRepoDir, 'packages/egg'); const mockDir = path.join(monoRepoDir, 'plugins/mock'); - execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir }); const { stdout: testStdout } = execaCommandSync('pnpm test:local', { cwd: projectDir }); expect(testStdout).toContain('2 passed'); - } + } finally { + fs.rmSync(localTemp, { recursive: true, force: true }); + } + } );And similarly for the tegg test:
test.skipIf(process.platform === 'win32')('successfully scaffolds a project based on tegg starter template', () => { - const projectName = 'create-egg-test-tegg'; - const { stdout } = run([projectName, '--template', 'tegg'], { - cwd: tempDir, - }); - const projectDir = path.join(tempDir, projectName); - const generatedFiles = fs.readdirSync(projectDir).sort(); + const prefix = path.join(tmpdir(), 'create-egg-'); + const localTemp = fs.mkdtempSync(prefix); + try { + const projectName = 'create-egg-test-tegg'; + const { stdout } = run([projectName, '--template', 'tegg'], { + cwd: localTemp, + }); + const projectDir = path.join(localTemp, projectName); + const generatedFiles = fs.readdirSync(projectDir).sort(); // Assertions expect(stdout).toContain(`Scaffolding project with`); - expect(generatedFiles).matchSnapshot(); + expect(generatedFiles).toMatchSnapshot(); // run test const monoRepoDir = path.join(import.meta.dirname, '../../../'); const eggDir = path.join(monoRepoDir, 'packages/egg'); const mockDir = path.join(monoRepoDir, 'plugins/mock'); - execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir }); + execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir }); const { stdout: testStdout } = execaCommandSync('pnpm test:local', { cwd: projectDir }); expect(testStdout).toContain('2 passed'); -}); + } finally { + fs.rmSync(localTemp, { recursive: true, force: true }); + } +});If you adopt this, you can drop the top-level tempDir and its afterAll cleanup.
Also applies to: 135-154
15-16: LGTM: mkdtemp prefix and global cleanupCorrect mkdtemp prefix usage and an afterAll cleanup are in place. This unblocks the EACCES/FS issues seen earlier.
Also applies to: 50-50
| // Assertions | ||
| expect(stdout).toContain(`Scaffolding project with`); | ||
| expect(generatedFiles).matchSnapshot(); | ||
|
|
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.
Use Vitest’s toMatchSnapshot()
The matcher should be toMatchSnapshot(); matchSnapshot() will fail.
Apply this diff:
- expect(generatedFiles).matchSnapshot();
+ expect(generatedFiles).toMatchSnapshot();- expect(generatedFiles).matchSnapshot();
+ expect(generatedFiles).toMatchSnapshot();Also applies to: 143-146
🤖 Prompt for AI Agents
In tools/create-egg/test/cli.test.ts around lines 119-122 (and also apply same
change at 143-146), the test uses the incorrect matcher matchSnapshot(); replace
matchSnapshot() with Vitest’s toMatchSnapshot() on the generatedFiles assertion
so it reads expect(generatedFiles).toMatchSnapshot(); keep the surrounding
assertions unchanged.

🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests
Chores
Misc
Documentation