Skip to content

Improve test performance (reduce CI time) #2481

@afonsojramos

Description

@afonsojramos

Problem

The test suite takes ~2 minutes in CI, with significant overhead in module imports and environment setup rather than actual test execution.

From a recent CI run analysis:

  • Total duration: 99s
  • Import time: 114.85s (main bottleneck!)
  • Environment setup: 38.39s
  • Actual test execution: 17.93s

Slowest Test Files

File Duration Tests
src/routes/LoginWithOAuthApp.test.tsx 1794ms 10
src/components/settings/NotificationSettings.test.tsx 1615ms 14
src/routes/Accounts.test.tsx 1452ms 12
src/routes/LoginWithPersonalAccessToken.test.tsx 1369ms 10
src/components/Sidebar.test.tsx 1364ms 16

Proposed Solutions

1. Enable parallel test execution

Add pool: 'threads' or pool: 'forks' to vitest.config.ts to run test files in parallel.

2. Consider happy-dom instead of jsdom

happy-dom is ~2-3x faster than jsdom. Trade-off: slightly less compatible but sufficient for most React tests.

// vitest.config.ts
environment: 'happy-dom',

3. Optimize @primer/react imports

The @primer/react library is heavy. Consider:

  • Barrel file optimization
  • Lazy loading in tests where possible
  • Mocking more aggressively in unit tests

4. Add test isolation

Currently inlining @primer/react and @primer/css. This may cause repeated parsing. Consider alternative approaches.

5. Split test workflow

Run fast unit tests separately from slower integration tests.

Success Criteria

  • Reduce CI test time from ~2 minutes to under 1 minute
  • No reduction in test coverage or reliability

Metadata

Metadata

Assignees

Labels

priority:mediumItems of medium importance. Applicable to most users or use-casestestEnhancements to test coverage or quality

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions