Skip to content

E2e cli for cross-sdk tests#1122

Open
MichaelGHSeg wants to merge 19 commits intomasterfrom
e2e-cli-work
Open

E2e cli for cross-sdk tests#1122
MichaelGHSeg wants to merge 19 commits intomasterfrom
e2e-cli-work

Conversation

@MichaelGHSeg
Copy link

No description provided.

MichaelGHSeg and others added 4 commits February 9, 2026 12:05
Node-based CLI that copies SDK upload/error-handling logic for e2e
testing against mock server. Includes E2E_TEST_SUITES for selective
test execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make apiHost and cdnHost optional in the CLI input type contract.
Add e2e-cli README documenting the input/output format and parameters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace copied SDK functions with real imports from the SDK source.
Events now flow through the full pipeline: SegmentClient → Timeline →
SegmentDestination (batch chunking) → QueueFlushingPlugin (queue) →
uploadEvents HTTP POST.

Three minimal stubs replace React Native runtime dependencies:
- react-native: mocks AppState, NativeModules, Platform
- @segment/sovran-react-native: re-exports real store.ts + bridge.ts,
  bypassing the RN bridge entry point
- react-native-get-random-values: no-op (Node.js has native crypto)

Uses esbuild to bundle CLI + SDK source + stubs into dist/cli.js.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MichaelGHSeg MichaelGHSeg requested a review from abueide February 11, 2026 17:56
MichaelGHSeg and others added 3 commits February 17, 2026 16:26
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per-SDK config and convenience script for the generic test runner
in sdk-e2e-tests. Run ./e2e-cli/run-e2e.sh to build and test locally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace hardcoded env vars and direct npm test call with
./scripts/run-tests.sh which reads e2e-config.json for test
configuration. This ensures CI uses the same config as local runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The e2e-cli directory has its own tsconfig and is not part of the
SDK's lint setup. Excluding it prevents ESLint parsing errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MichaelGHSeg and others added 4 commits February 20, 2026 10:59
- Align types with sdk-e2e-tests (AnalyticsEvent, EventSequence,
  CLIConfig, CLIOutput with sentBatches)
- Fix screen to use evt.name instead of evt.event
- Fix group to use evt.groupId instead of evt.event
- Replace non-null assertions with validation errors
- Add page event type (throws: not supported on mobile)
- Add default case for unknown event types
- Remove AsyncStoragePersistor export from sovran stub (pulls in
  @react-native-async-storage which breaks Node.js)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mobile SDKs don't have a page method. Kotlin and Swift CLIs already
map page → screen silently. Match that behavior here instead of
throwing an error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CLI should be a thin pass-through so e2e tests observe actual
SDK behavior for missing fields, not CLI pre-validation errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use team-suggested validation pattern: warn on missing/invalid
required fields and skip the event, validate optional fields and
proceed without them if invalid, catch per-event errors so one
bad event doesn't fail the entire sequence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

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

This PR introduces an E2E test CLI for the analytics-react-native SDK that enables running the complete SDK pipeline on Node.js without a React Native runtime. The CLI stubs React Native dependencies (AppState, NativeModules, sovran native bridge, AsyncStorage) with minimal Node.js equivalents, allowing the full event processing pipeline to execute in a standard Node.js environment. This enables automated cross-SDK E2E testing in CI/CD pipelines.

Changes:

  • Added e2e-cli package with TypeScript source, build configuration, and React Native stubs
  • Implemented CLI that accepts JSON input defining event sequences and outputs success/failure status
  • Added GitHub Actions workflow to run E2E tests against the sdk-e2e-tests repository
  • Added shell script to build the CLI and invoke the test suite

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
e2e-cli/tsconfig.json TypeScript configuration with path mappings for React Native stubs
e2e-cli/src/stubs/sovran.ts Stub re-exporting pure TypeScript implementations from sovran package
e2e-cli/src/stubs/react-native.ts Minimal React Native API stub providing AppState, NativeModules, and Platform
e2e-cli/src/stubs/react-native-get-random-values.ts No-op stub relying on Node.js 18+ native crypto
e2e-cli/src/cli.ts Main CLI implementation processing events through the real SDK pipeline
e2e-cli/run-e2e.sh Shell script to build CLI and run E2E tests
e2e-cli/package.json Package configuration with dependencies and build scripts
e2e-cli/package-lock.json Lock file for deterministic dependency installation
e2e-cli/e2e-config.json E2E test suite configuration
e2e-cli/build.js esbuild configuration bundling CLI with SDK source and stubs
e2e-cli/README.md Usage documentation and API specification
e2e-cli/.gitignore Ignoring node_modules and dist directories
.github/workflows/e2e-tests.yml GitHub Actions workflow for automated E2E testing
.eslintignore Excluding e2e-cli from ESLint checks
Files not reviewed (1)
  • e2e-cli/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

MichaelGHSeg and others added 7 commits February 24, 2026 16:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Update output examples to include sentBatches, add note explaining
it's always 0 since the SDK doesn't expose batch count tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix properties/traits validation to reject null and arrays
- Use generic signature for Platform.select stub
- Clarify logger and page→screen mapping with comments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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