test(cli-e2e): add E2E testing package and CI workflow#870
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Claude finished @binoy14's task in 2m 15s —— View job Tasks
ReviewChangeset: Not required — this is a test-only PR with no public API/behavior changes. Correctly omitted. Issues1.
Fix: use a fallback instead of throwing: SANITY_AUTH_TOKEN: process.env.SANITY_E2E_TOKEN ?? '',Then add a separate guard in 2.
The variable is named const tgzFilename = lines.findLast((line) => line.endsWith('.tgz'))
return join(packDest, tgzFilename)3.
const code = char.toLowerCase().codePointAt(0)! - 96This silently produces nonsensical control codes for non-alphabetic characters (e.g. const code = char.toLowerCase().codePointAt(0)! - 96
if (code < 1 || code > 26) {
throw new Error(`sendControl: expected a letter a-z, got "${char}"`)
}4.
The CI workflow passes 5.
The latest stable |
📦 Bundle Stats —
|
| Metric | Value | vs main (b27d532) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 10.94 MB | - |
| Bundled (gzip) | 2.05 MB | - |
| Import time | 838ms | -7ms, -0.8% |
bin:sanity
| Metric | Value | vs main (b27d532) |
|---|---|---|
| Internal (raw) | 975 B | - |
| Internal (gzip) | 460 B | - |
| Bundled (raw) | 9.84 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.98s | -7ms, -0.4% |
🗺️ 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 (b27d5327)
| Metric | Value | vs main (b27d532) |
|---|---|---|
| Internal (raw) | 93.1 KB | - |
| Internal (gzip) | 21.9 KB | - |
| Bundled (raw) | 21.62 MB | - |
| Bundled (gzip) | 3.42 MB | - |
| Import time | 793ms | +0ms, +0.0% |
🗺️ 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 (b27d5327)
| Metric | Value | vs main (b27d532) |
|---|---|---|
| Internal (raw) | 976 B | - |
| Internal (gzip) | 507 B | - |
| Bundled (raw) | 50.7 KB | - |
| Bundled (gzip) | 12.6 KB | - |
| 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.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Coverage DeltaNo covered files changed in this PR. Overall Coverage
|
This comment was marked as outdated.
This comment was marked as outdated.
b187a49 to
c0b713b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
@claude add SANITY_E2E_PROJECT_ID to turbo.json global env vars |
|
Claude finished @binoy14's task in 36s —— View job Adding
|
5091d84 to
e640b79
Compare
This comment was marked as outdated.
This comment was marked as outdated.
db1dca6 to
7f876fd
Compare
18d29e1 to
a7a20ce
Compare
a7a20ce to
a59e92b
Compare
b1a21a6 to
8b9c074
Compare
8b9c074 to
a0ac2b5
Compare
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
1e64481 to
45fc3ca
Compare
8a50948 to
6448c9f
Compare
b648ee4 to
314ecf4
Compare
df7e11e to
47d5997
Compare
Add a new @sanity/cli-e2e package for end-to-end testing of the Sanity CLI. The package uses pnpm pack to create a tarball of @sanity/cli, installs it into a temp directory via npm, then runs tests against the real binary. This ensures E2E tests exercise the actual published distribution. Includes: - globalSetup that packs and installs the CLI tarball - runCli() helper wrapping cli-testing-library's render() - Two initial tests: datasets list and --help - GitHub Actions E2E workflow - Vite compatibility fixes, env loading, and test isolation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47d5997 to
1b1aea7
Compare
mttdnt
left a comment
There was a problem hiding this comment.
Looks good, tested it out locally and the testing api makes sense to me. Just leaving a couple questions,
There was a problem hiding this comment.
Just one question if there was a pattern in mind for needing to find a specific value in a list and select. Is the idea to keep using sendKey until a certain value. IE finding the right project in a project select prompt.
There was a problem hiding this comment.
not yet but maybe it might be needed at one point. Keeping the API surface minimal till it's actually needed is my thinking
There was a problem hiding this comment.
add the dataset env to the example?
There was a problem hiding this comment.
It might not be needed, I might have to tweak this as I write more tests

Summary
This PR builds the core E2E testing infrastructure for the Sanity CLI, with real PTY support for interactive tests.
E2E Package (
@sanity/cli-e2e)pnpm packin vitest global setup, ensuring thefilesfield, lifecycle scripts, andbinentries are correctpnpm test:e2e(not included inpnpm test).github/workflows/e2e.yml) with path-based filtering and Node 20/22/24 matrixDual-mode process spawning
runCli()helper with TypeScript overloads:interactive: false(default) returns{stdout, stderr, exitCode, error},interactive: truereturnsInteractiveSessionchild_process.spawnwith separate stdout/stderr streamsnode-ptyfor real PTY allocation (isTTY === true), enabling@inquirer/promptsto rendernode-ptytypes leak to consumersInteractiveSession API
waitForText(pattern, opts?)— polls ANSI-stripped output for regex matchsendKey(key)— sends terminal escape sequences (Enter,ArrowUp, etc.)sendControl(char)— sends Ctrl+key combos (e.g., Ctrl+C)write(text)— raw stdin writeswaitForExit(timeout?)/kill()— process lifecycleonTestFinishedInitial test coverage
sanity --helpandsanity datasets list(authenticated + unauthenticated scenarios)Closes SDK-1188
Closes SDK-1190
Closes SDK-1194
Closes SDK-1196
🤖 Generated with Claude Code