Skip to content

test: test exports match for CLI versions#315

Merged
binoy14 merged 6 commits into
mainfrom
sdk-700
Jan 28, 2026
Merged

test: test exports match for CLI versions#315
binoy14 merged 6 commits into
mainfrom
sdk-700

Conversation

@binoy14
Copy link
Copy Markdown
Contributor

@binoy14 binoy14 commented Jan 20, 2026

Adds a test to compare exports and type exports from current CLI and new CLI to ensure we don't break any exports. The test is currently just logging the changes instead of failing the test

@linear
Copy link
Copy Markdown

linear Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor Author

binoy14 commented Jan 20, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude Bot commented Jan 20, 2026

Claude finished @binoy14's task in 57s —— View job


Code Review

  • Read repository guidelines
  • Review test file changes
  • Review other file changes
  • Provide feedback

Issues Found

1. Silent test failure (lines 129-148)
The second test catches assertion errors but swallows them, only logging to console. This defeats the purpose of having a test. Either:

  • Remove the try-catch block entirely if you want the test to fail
  • Use test.skip() or test.todo() if it's intentionally not enforced yet

2. Unsafe type assertion (line 50 in readPackageJson.ts)
When skipSchemaValidation is true, the code uses as PackageJson without validation. This is used in the test at line 71 where downloaded package.json is read. If the old CLI version has a malformed package.json, it will silently return invalid data and cause cryptic errors downstream.

3. Error property access without check (line 146)
error.expected and error.actual are accessed without verifying they exist. If the error shape is different, this will throw.

4. Missing error type checking (line 44)
error.code is accessed without narrowing the error type. Add proper type guard.

5. Unnecessary dependency
@vitest/utils is added only for the diff function. Consider if this is worth the dependency or if you can use a simpler approach like just logging the arrays directly.

6. Test relies on external network
The test downloads from npm registry (line 51). If npm is down or the package is unpublished, the test fails. Consider mocking or caching this for reliability.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 20, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 73.82% 5973 / 8091
🔵 Statements 73.13% 6125 / 8375
🔵 Functions 67.25% 908 / 1350
🔵 Branches 61.02% 2654 / 4349
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/cli/src/util/readPackageJson.ts 100% 100% 100% 100%
Generated in workflow #1812 for commit d3090d6 by the Vitest Coverage Report Action

@binoy14 binoy14 changed the base branch from main to graphite-base/315 January 21, 2026 04:44
@binoy14 binoy14 changed the base branch from graphite-base/315 to 01-20-chore_build_use_pkg-utils_to_generate_types January 21, 2026 04:44
@binoy14 binoy14 force-pushed the sdk-700 branch 3 times, most recently from d1e40db to d905449 Compare January 21, 2026 16:52
@binoy14 binoy14 force-pushed the 01-20-chore_build_use_pkg-utils_to_generate_types branch from 92cfa7a to ddea860 Compare January 21, 2026 17:52
@binoy14 binoy14 force-pushed the 01-20-chore_build_use_pkg-utils_to_generate_types branch from ddea860 to e0d9ac5 Compare January 23, 2026 04:21
@binoy14 binoy14 force-pushed the 01-20-chore_build_use_pkg-utils_to_generate_types branch from e0d9ac5 to a01e115 Compare January 23, 2026 22:50
@binoy14 binoy14 force-pushed the sdk-700 branch 2 times, most recently from 1a5b2cd to c1ad3f9 Compare January 23, 2026 22:56
@binoy14 binoy14 force-pushed the 01-20-chore_build_use_pkg-utils_to_generate_types branch from 8e5fa31 to 9fbe207 Compare January 26, 2026 01:46
@binoy14 binoy14 force-pushed the sdk-700 branch 2 times, most recently from 58016b0 to ddc92c3 Compare January 26, 2026 01:50
@binoy14 binoy14 force-pushed the 01-20-chore_build_use_pkg-utils_to_generate_types branch from 9fbe207 to 9f29121 Compare January 26, 2026 01:50
@binoy14 binoy14 changed the base branch from 01-20-chore_build_use_pkg-utils_to_generate_types to graphite-base/315 January 26, 2026 05:55
@binoy14 binoy14 changed the base branch from graphite-base/315 to main January 26, 2026 19:35
@binoy14 binoy14 marked this pull request as ready for review January 26, 2026 21:24
@binoy14 binoy14 requested a review from a team as a code owner January 26, 2026 21:24
@binoy14 binoy14 requested review from ryanbonial and removed request for a team January 26, 2026 21:24
@binoy14 binoy14 requested a review from rexxars January 26, 2026 21:25
@binoy14 binoy14 merged commit d8640cf into main Jan 28, 2026
54 of 59 checks passed
@binoy14 binoy14 deleted the sdk-700 branch January 28, 2026 19:50
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.

2 participants