Skip to content

E2e cli for cross-sdk tests#1122

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

E2e cli for cross-sdk tests#1122
MichaelGHSeg wants to merge 8 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>
break;
case 'screen':
await client.screen(
evt.event!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be event.name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also we should probably handle the cases where a field on event is missing instead of using null suppression ! operator. that way if some one passes an invalid event to --input, we don't get a vague runtime error

break;
case 'group':
await client.group(
evt.event!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be evt.groupId

Persistor,
PersistenceConfig,
} from '../../../packages/sovran/src/persistor/persistor';
export { AsyncStoragePersistor } from '../../../packages/sovran/src/persistor/async-storage-persistor';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exporting AsyncStoragePersistor will cause @react-native-async-storage/async-storage to be required which won't work with the CLI

};
}

interface CLIOutput {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the e2e project we have sentBatches defined as a required parameter, but its not defined here in the cli tool. also it might be worth creating a library that exports common types used by both the client and server, but i'll leave that value judgement to you whether there are enough shared types to justify it.

}

for (const evt of sequence.events) {
switch (evt.type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing page event type

events: Array<{
type: string;
event?: string;
userId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing anonymousId, messageId, and timestamp.

apiHost?: string;
cdnHost?: string;
sequences: Array<{
delayMs: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would separate the sequences and events into their own type like you did in the main repo

}>;
}>;
config?: {
flushAt?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here i would split config into its own type, and add the missing maxRetries field

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

Comments