Skip to content

chore(test): always report vitest worst import time offenders#1428

Merged
filmaj merged 1 commit into
mainfrom
report-test-import-times
Jul 2, 2026
Merged

chore(test): always report vitest worst import time offenders#1428
filmaj merged 1 commit into
mainfrom
report-test-import-times

Conversation

@filmaj

@filmaj filmaj commented Jul 2, 2026

Copy link
Copy Markdown
Member

Description

Enables reporting the worst offenders in terms of import times when running tests. More details about this in the Profiling Test Performance Vitest guide.

The use of barrel files in this repository is the top contributor to long import times, but poor mocking in tests is also a factor.

Here is what this addition prints at the end of any vitest test runs (the following taken from this Node 26 on ubuntu CI run in this PR):

Test Files  245 passed (245)
      Tests  2585 passed | 7 skipped (2592)
   Start at  18:17:43
   Duration  63.16s (transform 16.05s, setup 956ms, import 128.57s, tests 16.27s, environment 18ms)

Import Duration Breakdown (Top 10)

Module                                               Self  Total
.../src/hooks/prerun/__tests__/warnings.test.ts     3.09s  3.26s  ████████████████████
...mmandNotFound/__tests__/topicAliases.test.ts     2.27s  2.90s  ██████████████████░░
...ests__/init/init.get-project-details.test.ts     115ms  2.49s  ███████████████░░░░░
.../__tests__/compareDependencyVersions.test.ts      25ms  1.92s  ████████████░░░░░░░░
 ↳ ...ty/cli/src/util/compareDependencyVersions.ts   15ms  1.90s  ████████████░░░░░░░░
 ↳ ...ty/cli-build/src/_exports/_internal/build.ts   63ms  1.88s  ████████████░░░░░░░░
 ↳ ...nity/cli-build/src/actions/build/buildApp.ts  139ms  1.77s  ███████████░░░░░░░░░
...ity/cli/src/commands/__tests__/login.test.ts      84ms  1.55s  █████████░░░░░░░░░░░
...src/actions/build/__tests__/buildApp.test.ts     168ms  1.51s  █████████░░░░░░░░░░░
...orker/__tests__/renderDocumentWorker.test.ts     180ms  1.49s  █████████░░░░░░░░░░░

Total imports: 2249
Slowest import (total-time): 3.26s
Total import time (self/total): 85.38s / 590.59s

Note

Low Risk
Config-only test tooling with no runtime or production impact.

Overview
Enables Vitest’s experimental importDurations in the root vitest.config.ts so every test run prints the top 10 slowest imports (self vs total time) plus aggregate import stats at the end of the run.

This is observability only—no change to which tests run, coverage, or reporters. It’s meant to surface heavy import chains (e.g. barrel files) and tests that pull in too much of the app without mocking.

Reviewed by Cursor Bugbot for commit 31aa7ce. Bugbot is set up for automated code reviews on this repo. Configure here.

@filmaj filmaj self-assigned this Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (da1f49e0)

@sanity/cli

Metric Value vs main (da1f49e)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 885ms +13ms, +1.5%

bin:sanity

Metric Value vs main (da1f49e)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.24s -19ms, -0.8%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against main (da1f49e0)

Metric Value vs main (da1f49e)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 781ms +2ms, +0.3%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against main (da1f49e0)

Metric Value vs main (da1f49e)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@filmaj filmaj force-pushed the report-test-import-times branch from 9cb4163 to 4746f84 Compare July 2, 2026 18:16
@filmaj filmaj marked this pull request as ready for review July 2, 2026 18:16
@filmaj filmaj requested a review from a team as a code owner July 2, 2026 18:16
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

No covered files changed in this PR.

Overall Coverage

Metric Coverage
Statements 73.5% (±0%)
Branches 63.6% (±0%)
Functions 67.2% (- 0.0%)
Lines 74.1% (±0%)

@filmaj filmaj force-pushed the report-test-import-times branch from 4746f84 to 31aa7ce Compare July 2, 2026 18:25
@filmaj filmaj requested a review from a team July 2, 2026 18:25
@filmaj filmaj enabled auto-merge (squash) July 2, 2026 18:25
@filmaj filmaj merged commit 1a7625c into main Jul 2, 2026
49 of 50 checks passed
@filmaj filmaj deleted the report-test-import-times branch July 2, 2026 18:37
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.

3 participants