Skip to content

test: refine Istanbul/Vitest coverage exclude globs#2262

Open
xxiaoxiong wants to merge 1 commit into
stacklok:mainfrom
xxiaoxiong:fix/refine-test-coverage-excludes-596
Open

test: refine Istanbul/Vitest coverage exclude globs#2262
xxiaoxiong wants to merge 1 commit into
stacklok:mainfrom
xxiaoxiong:fix/refine-test-coverage-excludes-596

Conversation

@xxiaoxiong
Copy link
Copy Markdown

Summary

Refines test coverage exclusions to exclude generated files and shadcn/ui components, as requested in #596.

Changes

Added the following exclusions to vitest.config.ts coverage configuration:

1. Generated files

'**/*.gen.ts',
'**/*.gen.tsx',
'renderer/src/route-tree.gen.ts',

Rationale: These files are auto-generated (e.g., by TanStack Router plugin) and should not be modified or tested directly.

2. shadcn/ui components

'renderer/src/common/components/ui/**',

Rationale: As mentioned in the issue, shadcn/ui components are generated/copied from the shadcn/ui library and should almost never be individually tested in this project. Testing them would:

  • Inflate coverage metrics without adding value
  • Test third-party code rather than project-specific logic
  • Create maintenance burden for code we don't own

Impact

Before

  • Coverage included auto-generated files
  • Coverage included third-party UI components
  • Metrics were inflated with non-project code

After

  • Coverage focuses on project-specific code
  • More accurate representation of actual test coverage
  • Overall coverage percentage should rise (as stated in issue)

Testing

Verification steps

  1. Run tests with coverage:

    pnpm run test:coverage
  2. Verify that coverage report excludes:

    • renderer/src/route-tree.gen.ts
    • All files in renderer/src/common/components/ui/
    • Any other *.gen.ts or *.gen.tsx files
  3. Confirm CI still passes

Expected results

  • CI passes
  • Coverage percentage increases (excludes untested generated code)
  • Coverage report is cleaner and more focused

Related

Fixes #596

- Add exclusion for all generated files (*.gen.ts, *.gen.tsx)
- Explicitly exclude renderer/src/route-tree.gen.ts (TanStack Router)
- Exclude shadcn/ui components (renderer/src/common/components/ui/**)
  - These are generated/copied from shadcn/ui
  - Should not be individually tested in this project
  - Testing them would inflate coverage without value

This improves coverage accuracy by excluding code that:
1. Is auto-generated and should not be modified
2. Is third-party UI components not specific to this project

Fixes stacklok#596
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 485d865e1b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vitest.config.ts
'**/*.gen.tsx',
'renderer/src/route-tree.gen.ts',
// shadcn/ui components (generated, not project-specific)
'renderer/src/common/components/ui/**',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Narrow the UI coverage exclusion to generated shadcn files

This blanket exclude hides coverage for every component in renderer/src/common/components/ui, but that directory also contains project-specific code such as file-picker-input.tsx, loading-state-alert.tsx, input-search.tsx, and circular-status-icon.tsx, not just copied shadcn primitives. In coverage runs, bugs or untested branches in those local components will no longer be reflected at all, which makes the coverage report less accurate than before; please exclude only the actual generated shadcn primitives or move custom components out of this excluded path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refines Vitest coverage exclusions to omit generated code and vendor-copied UI components, aligning coverage reporting with project-owned logic (per #596).

Changes:

  • Excludes generated files from coverage via **/*.gen.ts, **/*.gen.tsx, and renderer/src/route-tree.gen.ts.
  • Excludes renderer/src/common/components/ui/** from coverage to omit shadcn/ui-derived components.

Comment thread vitest.config.ts
Comment on lines +56 to +57
// shadcn/ui components (generated, not project-specific)
'renderer/src/common/components/ui/**',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test coverage: Refine Istanbul/Vitest exclude globs

2 participants