@devries-cameron20 / composio Mirror · read-only / commits / 6aa99bc80
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 13:15 UTC

feat(ts/e2e): use bun:test for "pnpm test:e2e:node"; optimize Dockerfile.node

jkomyno committed Jan 26, 2026 at 22:32 UTC 6aa99bc80fb365f2161e480cc85aa5f770a06144
36 files changed +717 -550
package.json
+4 -4
@@ -13,10 +13,10 @@
13 "build": "turbo build",
14 "build:bin": "turbo build:bin --filter=./ts/packages/cli",
15 "build:packages": "turbo build --filter=./ts/packages/**",
16 - "test": "turbo test --filter=./ts/packages/** --filter=!@test-e2e/*",
17 - "test:e2e": "turbo test:e2e --filter='@test-e2e/*'",
18 - "test:e2e:node": "turbo test:e2e:node --filter='@test-e2e/node-*'",
19 - "test:e2e:cloudflare": "turbo test:e2e:cloudflare --filter='@test-e2e/cf-*'",
16 + "test": "turbo test --filter=./ts/packages/** --filter=!@e2e-tests/*",
17 + "test:e2e": "turbo test:e2e --filter='@e2e-tests/*'",
18 + "test:e2e:node": "turbo test:e2e:node --filter='@e2e-tests/node-*'",
19 + "test:e2e:cloudflare": "turbo test:e2e:cloudflare --filter='@e2e-tests/cf-*'",
20 "test:ui": "vitest --ui",
21 "typecheck": "turbo typecheck --filter=./ts/packages/**",
22 "lint": "eslint ts/packages --ext .ts,.tsx",
ts/e2e-tests/README.md
+2 -2
@@ -60,7 +60,7 @@ pnpm test:e2e:cloudflare
60 ### Node.js Runtime Tests
61
62 1. Create a new directory under `runtimes/node/` (e.g., `runtimes/node/my-test`)
63 -2. Add a `package.json` with name `@test-e2e/node-my-test`
63 +2. Add a `package.json` with name `@e2e-tests/node-my-test`
64 3. Add `test:e2e` and `test:e2e:node` scripts
65 4. Create an `e2e.ts` file with inline configuration:
66
@@ -86,6 +86,6 @@ await e2e(import.meta.url, {
86 ### Cloudflare Runtime Tests
87
88 1. Create a new directory under `runtimes/cloudflare/` (e.g., `runtimes/cloudflare/my-test`)
89 -2. Add a `package.json` with name `@test-e2e/cf-my-test`
89 +2. Add a `package.json` with name `@e2e-tests/cf-my-test`
90 3. Add `test:e2e` and `test:e2e:cloudflare` scripts
91 4. Configure vitest with `@cloudflare/vitest-pool-workers`
ts/e2e-tests/_utils/Dockerfile.node
+38 -30
@@ -1,5 +1,6 @@
1 +# syntax=docker/dockerfile:1
2 # Reusable Dockerfile for Node.js e2e tests
2 -# Usage: docker build -f Dockerfile.node --build-arg NODE_VERSION=20.19.0 --build-arg TEST_DIR=... --build-arg TEST_CMD="node test.cjs" -t test-name .
3 +# Usage: docker build -f Dockerfile.node --build-arg NODE_VERSION=20.19.0 -t test-name .
4 #
5 # Uses official node:slim images. For multi-version testing, run the build/run
6 # multiple times with different NODE_VERSION values from the shell script.
@@ -14,36 +15,40 @@ ENV PATH="$BUN_INSTALL/bin:$PNPM_HOME:$PATH"
15
16 WORKDIR /app
17
17 -COPY package.json \
18 - .bun-version \
19 - ./
20 -
21 -RUN apt update -y && \
22 - apt install -y curl unzip
23 -
24 -# Install corepack (for pnpm) and bun
25 -RUN npm i -g corepack@latest \
26 - && corepack enable \
27 - && curl -fsSL https://bun.com/install | BUN_INSTALL=/usr/local bash \
28 - && bun --version
29 -
30 -# Copy pnpm workspace files
31 -COPY pnpm-lock.yaml \
32 - pnpm-workspace.yaml \
33 - .pnpmfile.cjs \
34 - tsconfig.base.json \
35 - tsdown.config.base.ts \
36 - ./
18 +# Install system dependencies with cache mounts
19 +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
20 + --mount=type=cache,target=/var/lib/apt,sharing=locked \
21 + apt-get update && \
22 + apt-get install -y --no-install-recommends ca-certificates curl unzip && \
23 + rm -rf /var/lib/apt/lists/*
24
38 -# Copy all ts/packages (pre-built)
39 -COPY ts/packages/ ./ts/packages/
25 +# Install corepack (for pnpm) with npm cache mount
26 +RUN --mount=type=cache,target=/root/.npm \
27 + npm i -g corepack@latest && \
28 + corepack enable
29 +
30 +# Install bun (version from .bun-version)
31 +COPY .bun-version ./
32 +RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash -s "bun-v$(cat .bun-version)" && \
33 + bun --version
34 +
35 +# Copy lockfile first for optimal layer caching
36 +COPY pnpm-lock.yaml ./
37 +
38 +# Copy workspace configuration files
39 +COPY package.json \
40 + pnpm-workspace.yaml \
41 + .pnpmfile.cjs \
42 + tsconfig.base.json \
43 + tsdown.config.base.ts \
44 + ./
45
41 -# Copy pre-install scripts
46 +# Copy pre-install scripts (rarely change)
47 COPY ts/scripts/pre-install.sh ./ts/scripts/pre-install.sh
48 COPY ts/scripts/pre-install/ ./ts/scripts/pre-install/
49
45 -# Copy e2e tests
46 -COPY ts/e2e-tests/ ./ts/e2e-tests/
50 +# Copy all ts/packages (pre-built)
51 +COPY ts/packages/ ./ts/packages/
52
53 # Install dependencies using pnpm
54 # Note: We intentionally don't use --mount=type=cache for the pnpm store here
@@ -54,13 +59,16 @@ RUN pnpm install --frozen-lockfile
59 # This is a simplified version of ts/packages/cli/scripts/build-binary.ts + install-binary.ts
60 WORKDIR /app/ts/packages/cli
61 RUN bun build ./src/bin.ts \
57 - --env DEBUG_OVERRIDE_* \
58 - --compile \
59 - --production \
60 - --outfile /usr/local/bin/composio
62 + --env DEBUG_OVERRIDE_* \
63 + --compile \
64 + --production \
65 + --outfile /usr/local/bin/composio
66
67 WORKDIR /app
68
69 +# Copy e2e tests last (changes frequently)
70 +COPY ts/e2e-tests/ ./ts/e2e-tests/
71 +
72 RUN chown -R node:node /app
73
74 # Pre-create Composio CLI cache directory to work around Bun issue #7967
ts/e2e-tests/_utils/package.json
+4
@@ -13,6 +13,10 @@
13 }
14 }
15 },
16 + "scripts": {
17 + "docker:build": "bun run scripts/docker-build.ts",
18 + "docker:clean": "bun run scripts/docker-clean.ts"
19 + },
20 "devDependencies": {
21 "typescript": "catalog:"
22 }
ts/e2e-tests/_utils/scripts/docker-build.ts new
+96
@@ -0,0 +1,96 @@
1 +#!/usr/bin/env bun
2 +/**
3 + * Builds Docker images for all well-known Node.js versions used by e2e tests.
4 + * This includes versions from WELL_KNOWN_NODE_VERSIONS and the current runtime version.
5 + */
6 +
7 +import { $ } from 'bun';
8 +import { resolve, dirname } from 'node:path';
9 +import { fileURLToPath } from 'node:url';
10 +import { WELL_KNOWN_NODE_VERSIONS } from '../src/const';
11 +
12 +const __dirname = dirname(fileURLToPath(import.meta.url));
13 +
14 +function getRepoRoot(): string {
15 + // From scripts/ to repo root: scripts -> _utils -> e2e-tests -> ts -> composio
16 + return resolve(__dirname, '../../../..');
17 +}
18 +
19 +function imageTagForNodeVersion(nodeVersion: string): string {
20 + return `composio-e2e-node:${nodeVersion}`;
21 +}
22 +
23 +function defaultLabels(nodeVersion: string): Record<string, string> {
24 + return {
25 + 'composio.e2e': 'true',
26 + 'composio.runtime': 'node',
27 + 'composio.node_version': nodeVersion,
28 + };
29 +}
30 +
31 +async function buildImage(nodeVersion: string, repoRoot: string): Promise<boolean> {
32 + const dockerfilePath = resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.node');
33 + const imageTag = imageTagForNodeVersion(nodeVersion);
34 + const labels = defaultLabels(nodeVersion);
35 + const labelArgs = Object.entries(labels)
36 + .map(([k, v]) => `--label=${k}=${v}`)
37 + .join(' ');
38 +
39 + console.log(`\nBuilding image for Node.js ${nodeVersion}...`);
40 +
41 + const result = await $`docker build -f ${dockerfilePath} --build-arg NODE_VERSION=${nodeVersion} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`
42 + .cwd(repoRoot)
43 + .nothrow();
44 +
45 + if (result.exitCode !== 0) {
46 + console.error(` Failed to build ${imageTag}:`);
47 + console.error(result.stderr.toString() || result.stdout.toString());
48 + return false;
49 + }
50 +
51 + console.log(` Built ${imageTag}`);
52 + return true;
53 +}
54 +
55 +async function main() {
56 + const repoRoot = getRepoRoot();
57 + const currentNodeVersion = process.versions.node;
58 +
59 + // Collect all unique Node versions to build
60 + const versions = new Set<string>();
61 +
62 + for (const version of WELL_KNOWN_NODE_VERSIONS) {
63 + if (version === 'current') {
64 + versions.add(currentNodeVersion);
65 + } else {
66 + versions.add(version);
67 + }
68 + }
69 +
70 + const versionList = Array.from(versions);
71 + console.log('Building Docker images for Node.js versions:');
72 + for (const v of versionList) {
73 + const isCurrent = v === currentNodeVersion ? ' (current)' : '';
74 + console.log(` - ${v}${isCurrent}`);
75 + }
76 +
77 + let failed = 0;
78 + for (const version of versionList) {
79 + const success = await buildImage(version, repoRoot);
80 + if (!success) {
81 + failed++;
82 + }
83 + }
84 +
85 + console.log('\n---');
86 + console.log(`Built ${versionList.length - failed}/${versionList.length} images.`);
87 +
88 + if (failed > 0) {
89 + process.exit(1);
90 + }
91 +}
92 +
93 +main().catch((err) => {
94 + console.error('Error:', err);
95 + process.exit(1);
96 +});
ts/e2e-tests/_utils/scripts/docker-clean.ts new
+61
@@ -0,0 +1,61 @@
1 +#!/usr/bin/env bun
2 +/**
3 + * Removes all Docker images used by the Node.js e2e tests.
4 + * Images are identified by the label `composio.e2e=true` and `composio.runtime=node`.
5 + */
6 +
7 +import { $ } from 'bun';
8 +
9 +async function main() {
10 + console.log('Finding e2e Node.js Docker images...');
11 +
12 + // Find all images with the e2e labels
13 + const result = await $`docker images --filter label=composio.e2e=true --filter label=composio.runtime=node --format {{.Repository}}:{{.Tag}}`
14 + .nothrow()
15 + .quiet();
16 +
17 + if (result.exitCode !== 0) {
18 + console.error('Failed to list Docker images:', result.stderr.toString());
19 + process.exit(1);
20 + }
21 +
22 + const images = result.stdout
23 + .toString()
24 + .trim()
25 + .split('\n')
26 + .filter((img) => img.length > 0 && !img.includes('<none>'));
27 +
28 + if (images.length === 0) {
29 + console.log('No e2e Node.js Docker images found.');
30 + return;
31 + }
32 +
33 + console.log(`Found ${images.length} image(s) to remove:`);
34 + for (const img of images) {
35 + console.log(` - ${img}`);
36 + }
37 +
38 + console.log('\nRemoving images...');
39 +
40 + // Remove images one by one to safely handle each image name
41 + let removeFailures = 0;
42 + for (const img of images) {
43 + const removeResult = await $`docker rmi ${img}`.nothrow().quiet();
44 + if (removeResult.exitCode !== 0) {
45 + console.error(` Failed to remove ${img}:`, removeResult.stderr.toString());
46 + removeFailures++;
47 + }
48 + }
49 +
50 + if (removeFailures > 0) {
51 + console.error(`Failed to remove ${removeFailures} image(s).`);
52 + process.exit(1);
53 + }
54 +
55 + console.log('Done.');
56 +}
57 +
58 +main().catch((err) => {
59 + console.error('Error:', err);
60 + process.exit(1);
61 +});
ts/e2e-tests/_utils/src/config.ts
+21 -8
@@ -1,6 +1,7 @@
1 import { dirname, resolve } from 'node:path';
2 import { fileURLToPath } from 'node:url';
3 -import type { NodeVersion } from './types';
3 +import process from 'node:process';
4 +import type { NodeVersionMeta, NodeVersionFromUser } from './types';
5
6 /**
7 * Get the repository root path.
@@ -20,17 +21,29 @@ export function getRepoRoot(): string {
21 * 2. Provided nodeVersions from config
22 * 3. Current Node.js runtime version
23 */
23 -export function resolveNodeVersions(
24 - configNodeVersions?: readonly NodeVersion[]
25 -): readonly NodeVersion[] {
24 +export function resolveNodeVersionMetaList(
25 + configNodeVersions?: readonly NodeVersionFromUser[]
26 +): readonly NodeVersionMeta[] {
27 const envVersion = process.env.COMPOSIO_E2E_NODE_VERSION;
28 if (envVersion) {
28 - return [envVersion];
29 + return [{ kind: 'overridden', value: envVersion }];
30 }
31
31 - if (configNodeVersions && configNodeVersions.length > 0) {
32 - return configNodeVersions;
32 + const currentNodeVersion = process.versions.node;
33 +
34 + if (configNodeVersions === undefined) {
35 + return [{ kind: 'current', value: currentNodeVersion }];
36 }
37
35 - return [process.versions.node];
38 + const distinctNodeVersions = Array.from(
39 + new Set(
40 + configNodeVersions
41 + .map((v => v === 'current'
42 + ? { kind: 'current', value: currentNodeVersion } as const
43 + : { kind: 'static', value: v } as const)
44 + )
45 + )
46 + );
47 +
48 + return distinctNodeVersions;
49 }
ts/e2e-tests/_utils/src/const.ts new
+1
@@ -0,0 +1 @@
1 +export const WELL_KNOWN_NODE_VERSIONS = ['20.18.0', '20.19.0', '22.12.0', 'current'] as const;
ts/e2e-tests/_utils/src/e2e.ts
+28 -7
@@ -36,25 +36,46 @@ function inferCwd(importMetaUrl: string, repoRoot: string): string {
36 }
37
38 /**
39 - * Run an e2e test with inline configuration.
39 + * Run e2e tests with full bun:test capabilities.
40 *
41 - * This is the main entry point for e2e tests. It automatically infers
42 - * the working directory and suite name from the caller's location.
41 + * This function sets up bun:test describe/it blocks internally.
42 + * When the test file is run via `bun test`, the full bun:test API
43 + * is available in your defineTests callback.
44 *
45 * @param importMetaUrl - Pass `import.meta.url` from your test file
45 - * @param config - Test configuration
46 + * @param config - Test configuration with defineTests callback
47 *
48 * @example
49 * ```typescript
49 - * await e2e(import.meta.url, { fixture: 'fixtures/test.mjs' });
50 + * // e2e.test.ts
51 + * import { e2e } from '@e2e-tests/utils';
52 + * import type { E2ETestResult } from '@e2e-tests/utils';
53 + *
54 + * e2e(import.meta.url, {
55 + * nodeVersions: ['20.19.0', '22.12.0'],
56 + * env: { COMPOSIO_API_KEY: process.env.COMPOSIO_API_KEY },
57 + * defineTests: ({ describe, it, expect, beforeAll, runFixture }) => {
58 + * let result: E2ETestResult;
59 + *
60 + * beforeAll(async () => {
61 + * result = await runFixture('fixtures/test.mjs');
62 + * }, 300_000);
63 + *
64 + * describe('output', () => {
65 + * it('exits successfully', () => {
66 + * expect(result.exitCode).toBe(0);
67 + * });
68 + * });
69 + * },
70 + * });
71 * ```
72 */
52 -export async function e2e(importMetaUrl: string, config: E2EConfig): Promise<never> {
73 +export function e2e(importMetaUrl: string, config: E2EConfig): void {
74 validateImportMetaUrl(importMetaUrl);
75
76 const repoRoot = getRepoRoot();
77 const cwd = inferCwd(importMetaUrl, repoRoot);
78 const suiteName = cwd.split('/').pop() ?? 'unknown';
79
59 - return runE2E({ ...config, cwd, suiteName });
80 + runE2E({ ...config, cwd, suiteName });
81 }
ts/e2e-tests/_utils/src/image-lifecycle.ts
+28 -25
@@ -1,4 +1,4 @@
1 -import { spawn } from 'node:child_process';
1 +import { $ } from 'bun';
2 import { resolve } from 'node:path';
3 import { getRepoRoot } from './config';
4
@@ -56,6 +56,14 @@ export interface CheckDockerOptions {
56 repoRoot?: string;
57 }
58
59 +/**
60 + * Escapes a shell argument for safe use in Bun shell raw strings.
61 + */
62 +function escapeShellArg(arg: string): string {
63 + // Single-quote the arg and escape any embedded single quotes
64 + return `'${arg.replace(/'/g, "'\\''")}'`;
65 +}
66 +
67 /**
68 * Creates default Docker labels for e2e images.
69 */
@@ -71,7 +79,7 @@ function defaultLabels(nodeVersion?: string): Record<string, string> {
79 }
80
81 /**
74 - * Converts labels object to Docker CLI arguments.
82 + * Converts labels object to Docker CLI arguments array.
83 */
84 function labelsToArgs(labels: Record<string, string> = {}): string[] {
85 const args: string[] = [];
@@ -82,36 +90,31 @@ function labelsToArgs(labels: Record<string, string> = {}): string[] {
90 }
91
92 /**
85 - * Executes a command and captures stdout/stderr.
93 + * Executes a command and captures stdout/stderr using Bun shell.
94 */
95 async function exec(cmd: string, args: string[], options: ExecOptions = {}): Promise<ExecResult> {
96 const { cwd, env } = options;
89 - const child = spawn(cmd, args, {
90 - cwd,
91 - env: env ? { ...process.env, ...env } : process.env,
92 - stdio: ['ignore', 'pipe', 'pipe'],
93 - });
94 -
95 - let stdout = '';
96 - let stderr = '';
97 + const escapedArgs = args.map(escapeShellArg).join(' ');
98
98 - child.stdout.setEncoding('utf8');
99 - child.stderr.setEncoding('utf8');
99 + let shell = $`${{ raw: cmd }} ${{ raw: escapedArgs }}`
100 + .nothrow()
101 + .quiet();
102
101 - child.stdout.on('data', (d: string) => {
102 - stdout += d;
103 - });
103 + if (cwd) {
104 + shell = shell.cwd(cwd);
105 + }
106
105 - child.stderr.on('data', (d: string) => {
106 - stderr += d;
107 - });
107 + if (env) {
108 + shell = shell.env({ ...process.env, ...env });
109 + }
110
109 - const code = await new Promise<number>((res, rej) => {
110 - child.on('error', rej);
111 - child.on('close', (exitCode) => res(exitCode ?? 1));
112 - });
111 + const result = await shell;
112
114 - return { exitCode: code, stdout, stderr };
113 + return {
114 + exitCode: result.exitCode,
115 + stdout: result.stdout.toString(),
116 + stderr: result.stderr.toString(),
117 + };
118 }
119
120 /**
@@ -145,7 +148,7 @@ export async function ensureNodeImage(
148 options: EnsureNodeImageOptions = {}
149 ): Promise<string> {
150 if (!nodeVersion || typeof nodeVersion !== 'string') {
148 - throw new Error('ensureNodeImage(nodeVersion): nodeVersion must be a non-empty string');
151 + throw new Error(`ensureNodeImage(${nodeVersion}): nodeVersion must be a non-empty string`);
152 }
153
154 const repoRoot = options.repoRoot ?? getRepoRoot();
ts/e2e-tests/_utils/src/index.ts
+2 -2
@@ -1,3 +1,3 @@
1 -export type { E2EConfig, E2ETestResult, E2EPhaseResults, E2EAssertionCallback } from './types';
1 +export type { E2EConfig, E2ETestResult, DefineTestsContext, NodeVersionMeta as NodeVersion } from './types';
2 export { e2e } from './e2e';
3 -export { checkDocker } from './image-lifecycle';
3 +export { sanitizeOutput } from './sanitize';
ts/e2e-tests/_utils/src/runner.ts
+59 -206
@@ -1,8 +1,7 @@
1 -import { writeFileSync, appendFileSync } from 'node:fs';
2 -import { resolve } from 'node:path';
3 -import type { E2EConfig, E2EPhaseResults, E2ETestResult } from './types';
4 -import { getRepoRoot, resolveNodeVersions } from './config';
5 -import { checkDocker, ensureNodeImage, runNodeContainer } from './image-lifecycle';
1 +import { describe, beforeAll } from 'bun:test';
2 +import type { E2EConfig, E2ETestResult, NodeVersionMeta } from './types';
3 +import { getRepoRoot, resolveNodeVersionMetaList } from './config';
4 +import { ensureNodeImage, runNodeContainer } from './image-lifecycle';
5
6 /**
7 * Environment variables to automatically pass through to Docker containers.
@@ -32,223 +31,77 @@ function buildContainerEnv(
31 }
32
33 /**
35 - * Initialize the DEBUG.log file with a header.
34 + * Internal configuration for runE2E.
35 */
37 -function initDebugLog(logPath: string, suiteName: string, nodeVersions: readonly string[]): void {
38 - const header = [
39 - `=== E2E Test: ${suiteName} ===`,
40 - `Started: ${new Date().toISOString()}`,
41 - `Node versions: ${nodeVersions.join(', ')}`,
42 - '',
43 - '',
44 - ].join('\n');
45 - writeFileSync(logPath, header, 'utf8');
36 +interface RunE2EInternalConfig extends E2EConfig {
37 + cwd: string;
38 + suiteName: string;
39 }
40
41 /**
49 - * Append a phase result to the DEBUG.log file.
42 + * Creates Docker execution utilities for a specific Node version.
43 */
51 -function appendPhaseToDebugLog(
52 - logPath: string,
44 +function createDockerExecutors(
45 + config: RunE2EInternalConfig,
46 nodeVersion: string,
54 - phaseName: 'Setup' | 'Test',
55 - result: E2ETestResult
56 -): void {
57 - const lines = [
58 - `=== ${phaseName} (Node ${nodeVersion}) ===`,
59 - '',
60 - '[stdout]',
61 - result.stdout || '(empty)',
62 - '',
63 - '[stderr]',
64 - result.stderr || '(empty)',
65 - '',
66 - `[exit code] ${result.exitCode}`,
67 - '',
68 - '',
69 - ];
70 - appendFileSync(logPath, lines.join('\n'), 'utf8');
71 -}
72 -
73 -/**
74 - * Append a summary to the DEBUG.log file.
75 - */
76 -function appendSummaryToDebugLog(
77 - logPath: string,
78 - results: E2EPhaseResults[],
79 - allPassed: boolean
80 -): void {
81 - const lines = ['=== Summary ===', ''];
82 - for (const r of results) {
83 - const status = r.test.exitCode === 0 ? 'PASS' : 'FAIL';
84 - lines.push(`Node ${r.nodeVersion}: ${status}`);
85 - }
86 - lines.push('');
87 - lines.push(allPassed ? 'All tests passed!' : 'Some tests failed');
88 - lines.push('');
89 - lines.push(`Finished: ${new Date().toISOString()}`);
90 - lines.push('');
91 - appendFileSync(logPath, lines.join('\n'), 'utf8');
92 -}
93 -
94 -/**
95 - * Default summary printer for e2e test results.
96 - */
97 -function printDefaultSummary(
98 - suiteName: string,
99 - results: E2EPhaseResults[],
100 - allPassed: boolean
101 -): void {
102 - const divider = '='.repeat(Math.max(suiteName.length + 4, 30));
103 -
104 - console.log(`\n${divider}`);
105 - console.log(`Test Summary`);
106 - console.log(divider);
107 -
108 - for (const r of results) {
109 - const testStatus = r.test.exitCode === 0 ? 'PASS' : 'FAIL';
110 - console.log(`Node ${r.nodeVersion}: ${testStatus}`);
111 - }
112 -
113 - if (allPassed) {
114 - console.log(`\nAll tests passed!`);
115 - } else {
116 - console.error(`\nSome tests failed`);
117 - }
118 -}
119 -
120 -/**
121 - * Internal configuration for runE2E.
122 - */
123 -interface RunE2EInternalConfig extends E2EConfig {
124 - cwd: string;
125 - suiteName: string;
47 + imageTag: string
48 +) {
49 + const { cwd, suiteName, env } = config;
50 + const containerEnv = buildContainerEnv(env);
51 +
52 + const runCmd = async (command: string): Promise<E2ETestResult> => {
53 + const containerName = `e2e-${suiteName}-${nodeVersion.replace(/\./g, '-')}-${Date.now()}`;
54 + return runNodeContainer({
55 + imageTag,
56 + cmd: command,
57 + cwd,
58 + env: containerEnv,
59 + name: containerName,
60 + });
61 + };
62 +
63 + const runFixture = async (fixturePath: string): Promise<E2ETestResult> => {
64 + return runCmd(`node ${fixturePath}`);
65 + };
66 +
67 + return { runCmd, runFixture };
68 }
69
70 /**
129 - * Runs e2e tests with Docker containers.
130 - *
131 - * For each Node version:
132 - * 1. Ensures Docker image exists (builds if needed)
133 - * 2. Runs setup command (if provided) and fixture in a single container
134 - * 3. Captures output and exit codes
135 - * 4. Calls assertion callbacks
136 - *
137 - * Writes detailed output to DEBUG.log and prints a summary.
71 + * Runs e2e tests using bun:test.
72 + * Creates a describe block per Node version and passes test utilities to defineTests.
73 */
139 -export async function runE2E(config: RunE2EInternalConfig): Promise<never> {
140 - const { cwd, suiteName, fixture, setup, env, onSetup, onTest, printSummary } = config;
141 - const nodeVersions = resolveNodeVersions(config.nodeVersions);
74 +export function runE2E(config: RunE2EInternalConfig): void {
75 + const { suiteName, defineTests } = config;
76 + const nodeVersionMetaList = resolveNodeVersionMetaList(config.nodeVersions);
77 const repoRoot = getRepoRoot();
143 - const debugLogPath = resolve(repoRoot, cwd, 'DEBUG.log');
144 -
145 - // Initialize DEBUG.log
146 - initDebugLog(debugLogPath, suiteName, nodeVersions);
147 - console.log(`Debug log: ${debugLogPath}`);
148 -
149 - // Print header
150 - console.log(`\n${suiteName}`);
151 - console.log('='.repeat(suiteName.length));
152 - console.log(`Node versions: ${nodeVersions.join(', ')}`);
153 - console.log(`Fixture: ${fixture}\n`);
154 -
155 - // Check Docker availability
156 - let dockerOk = false;
157 - let dockerFailureMessage = '';
158 - try {
159 - const dockerCheck = await checkDocker({ repoRoot });
160 - dockerOk = dockerCheck.exitCode === 0;
161 - dockerFailureMessage = dockerCheck.stderr || dockerCheck.stdout || '';
162 - } catch (error) {
163 - dockerOk = false;
164 - dockerFailureMessage = error instanceof Error ? error.message : String(error);
165 - }
78
167 - if (!dockerOk) {
168 - const reason = dockerFailureMessage.trim() || 'Docker is not available';
169 - const message = `Skipping e2e suite because Docker is not available. Reason: ${reason}`;
170 - console.log(message);
171 - appendFileSync(debugLogPath, `\n${message}\n`, 'utf8');
172 - process.exit(0);
79 + function renderNodeVersionMeta({ kind, value }: NodeVersionMeta) {
80 + switch (kind) {
81 + case 'current':
82 + return `Node.js ${value} [current]`;
83 + case 'overridden':
84 + return `Node.js ${value} [overridden]`;
85 + case 'static':
86 + return `Node.js ${value}`;
87 + }
88 }
89
175 - const results: E2EPhaseResults[] = [];
176 -
177 - try {
178 - for (const nodeVersion of nodeVersions) {
179 - console.log(`\n=== Running e2e test for Node.js ${nodeVersion} ===\n`);
180 -
181 - const imageTag = await ensureNodeImage(nodeVersion, { repoRoot });
90 + for (const nodeVersionMeta of nodeVersionMetaList) {
91 + describe(`${suiteName} (Node ${renderNodeVersionMeta(nodeVersionMeta)})`, () => {
92 + let executors: ReturnType<typeof createDockerExecutors>;
93
183 - const phaseResult: E2EPhaseResults = {
184 - nodeVersion,
185 - test: undefined as unknown as E2ETestResult,
186 - };
94 + // Ensure Docker image exists before tests run
95 + beforeAll(async () => {
96 + const imageTag = await ensureNodeImage(nodeVersionMeta.value, { repoRoot });
97 + executors = createDockerExecutors(config, nodeVersionMeta.value, imageTag);
98 + }, 600_000); // 10 minute timeout for Docker image build
99
188 - // Build combined command: setup (if provided) && fixture
189 - const fixtureCmd = `node ${fixture}`;
190 - const combinedCmd = setup ? `${setup} && ${fixtureCmd}` : fixtureCmd;
191 -
192 - if (setup) {
193 - console.log(`[Node ${nodeVersion}] Running setup: ${setup}`);
194 - }
195 - console.log(`[Node ${nodeVersion}] Running fixture: ${fixtureCmd}`);
196 -
197 - const containerName = `e2e-${suiteName}-${nodeVersion.replace(/\./g, '-')}`;
198 - const result = await runNodeContainer({
199 - imageTag,
200 - cmd: combinedCmd,
201 - cwd,
202 - env: buildContainerEnv(env),
203 - name: containerName,
100 + // Call user's defineTests with bun:test functions and Docker utilities
101 + defineTests({
102 + runCmd: (cmd) => executors.runCmd(cmd),
103 + runFixture: (path) => executors.runFixture(path),
104 });
205 -
206 - phaseResult.test = result;
207 -
208 - if (setup) {
209 - phaseResult.setup = result;
210 - console.log(`[Setup+Test stdout]\n${result.stdout || '(empty)'}`);
211 - console.log(`[Setup+Test stderr]\n${result.stderr || '(empty)'}`);
212 - console.log(`[Exit code] ${result.exitCode}\n`);
213 -
214 - appendPhaseToDebugLog(debugLogPath, nodeVersion, 'Setup', result);
215 - appendPhaseToDebugLog(debugLogPath, nodeVersion, 'Test', result);
216 -
217 - if (onSetup) {
218 - await onSetup(result);
219 - }
220 - } else {
221 - if (result.stdout) {
222 - console.log(`[Test stdout]\n${result.stdout}`);
223 - }
224 - if (result.stderr) {
225 - console.log(`[Test stderr]\n${result.stderr}`);
226 - }
227 - console.log(`[Test exit code] ${result.exitCode}\n`);
228 -
229 - appendPhaseToDebugLog(debugLogPath, nodeVersion, 'Test', result);
230 - }
231 -
232 - if (onTest) {
233 - await onTest(result);
234 - }
235 -
236 - results.push(phaseResult);
237 - }
238 -
239 - const allPassed = results.every((r) => r.test.exitCode === 0);
240 -
241 - appendSummaryToDebugLog(debugLogPath, results, allPassed);
242 -
243 - if (printSummary) {
244 - printSummary(results, allPassed);
245 - } else {
246 - printDefaultSummary(suiteName, results, allPassed);
247 - }
248 -
249 - process.exit(allPassed ? 0 : 1);
250 - } catch (error) {
251 - console.error('Test runner failed:', error);
252 - process.exit(1);
105 + });
106 }
107 }
ts/e2e-tests/_utils/src/sanitize.ts new
+26
@@ -0,0 +1,26 @@
1 +/**
2 + * Output sanitization utilities for stable test comparisons.
3 + */
4 +
5 +/**
6 + * Sanitize command output for stable snapshot comparisons.
7 + * Removes ANSI escape codes, normalizes line endings, and trims whitespace.
8 + *
9 + * @param output - Raw command output (stdout or stderr)
10 + * @returns Sanitized output suitable for assertions and snapshots
11 + */
12 +export function sanitizeOutput(output: string): string {
13 + return (
14 + output
15 + // Remove ANSI escape codes (colors, formatting)
16 + .replace(/\x1b\[[0-9;]*m/g, '')
17 + // Normalize line endings (Windows → Unix)
18 + .replace(/\r\n/g, '\n')
19 + // Trim trailing whitespace from each line
20 + .split('\n')
21 + .map((line) => line.trimEnd())
22 + .join('\n')
23 + // Trim leading/trailing whitespace from entire output
24 + .trim()
25 + );
26 +}
ts/e2e-tests/_utils/src/types.ts
+37 -41
@@ -1,4 +1,11 @@
1 -export type NodeVersion = '20.18.0' | '20.19.0' | '22.12.0' | (string & {});
1 +import { WELL_KNOWN_NODE_VERSIONS } from './const';
2 +
3 +export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];
4 +
5 +export type NodeVersionMeta =
6 + | { kind: 'static', value: Exclude<typeof WELL_KNOWN_NODE_VERSIONS[number], 'current'> }
7 + | { kind: 'overridden', value: string }
8 + | { kind: 'current', value: string };
9
10 /**
11 * Result of executing a command in a Docker container.
@@ -13,62 +20,51 @@ export interface E2ETestResult {
20 }
21
22 /**
16 - * Results for both phases of a two-phase e2e test.
23 + * Context passed to defineTests callback.
24 */
18 -export interface E2EPhaseResults {
19 - /** Node.js version this test ran against */
20 - nodeVersion: string;
21 - /** Result of the setup phase (undefined if no setup command) */
22 - setup?: E2ETestResult;
23 - /** Result of the test/fixture phase */
24 - test: E2ETestResult;
25 +export interface DefineTestsContext {
26 + /** Run an arbitrary command in the Docker container */
27 + runCmd: (command: string) => Promise<E2ETestResult>;
28 + /** Run a fixture file with Node.js (equivalent to runCmd(`node ${path}`)) */
29 + runFixture: (fixturePath: string) => Promise<E2ETestResult>;
30 }
31
27 -/**
28 - * Assertion callback for validating phase results.
29 - */
30 -export type E2EAssertionCallback = (result: E2ETestResult) => void | Promise<void>;
31 -
32 /**
33 * Configuration for e2e tests.
34 */
35 export interface E2EConfig {
36 - /**
37 - * The fixture file to execute (e.g., 'fixtures/test.mjs').
38 - */
39 - fixture: string;
40 -
36 /**
37 * Node.js versions to test against.
38 + * Each version creates a separate describe block.
39 * If not provided, defaults to the current Node runtime version.
40 */
45 - nodeVersions?: readonly NodeVersion[];
41 + nodeVersions?: readonly NodeVersionFromUser[];
42
43 /**
48 - * Setup command to run before the test fixture.
49 - * Runs inside the Docker container after dependencies are installed.
50 - */
51 - setup?: string;
52 -
53 - /**
54 - * Environment variables to pass to the container.
44 + * Environment variables to pass to the Docker container.
45 */
46 env?: Record<string, string | undefined>;
47
48 /**
59 - * Assertion callback for the setup phase.
60 - * Called after setup completes (if setup is defined).
61 - */
62 - onSetup?: E2EAssertionCallback;
63 -
64 - /**
65 - * Assertion callback for the test phase.
66 - * Called after the fixture completes.
67 - */
68 - onTest?: E2EAssertionCallback;
69 -
70 - /**
71 - * Custom summary printer. If not provided, uses default summary format.
49 + * Define your tests using bun:test primitives.
50 + * Called once per Node version during test registration.
51 + *
52 + * @example
53 + * ```typescript
54 + * defineTests: ({ describe, it, expect, beforeAll, runFixture }) => {
55 + * let result: E2ETestResult;
56 + *
57 + * beforeAll(async () => {
58 + * result = await runFixture('fixtures/test.mjs');
59 + * }, 300_000);
60 + *
61 + * describe('output', () => {
62 + * it('exits successfully', () => {
63 + * expect(result.exitCode).toBe(0);
64 + * });
65 + * });
66 + * }
67 + * ```
68 */
73 - printSummary?: (results: E2EPhaseResults[], allPassed: boolean) => void;
69 + defineTests: (ctx: DefineTestsContext) => void;
70 }
ts/e2e-tests/runtimes/cloudflare/cf-workers-basic/package.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 - "name": "@test-e2e/cf-workers-basic",
2 + "name": "@e2e-tests/cf-workers-basic",
3 "version": "0.0.0",
4 "private": true,
5 "type": "module",
ts/e2e-tests/runtimes/cloudflare/cf-workers-files/README.md
+1 -1
@@ -29,7 +29,7 @@ Verifies that:
29 pnpm test:e2e
30
31 # Or from the monorepo root
32 -pnpm --filter @test-e2e/cf-workers-files test:e2e:cloudflare
32 +pnpm --filter @e2e-tests/cf-workers-files test:e2e:cloudflare
33 ```
34
35 ## Environment Variables
ts/e2e-tests/runtimes/cloudflare/cf-workers-files/package.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 - "name": "@test-e2e/cf-workers-files",
2 + "name": "@e2e-tests/cf-workers-files",
3 "version": "0.0.0",
4 "private": true,
5 "type": "module",
ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/package.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 - "name": "@test-e2e/cf-workers-tool-router-ai",
2 + "name": "@e2e-tests/cf-workers-tool-router-ai",
3 "version": "0.0.0",
4 "private": true,
5 "type": "module",
ts/e2e-tests/runtimes/node/cjs-basic/e2e.test.ts new
+71
@@ -0,0 +1,71 @@
1 +/**
2 + * CommonJS compatibility e2e test
3 + *
4 + * Verifies that @composio/core can be imported using require() in Node.js.
5 + */
6 +
7 +import { e2e, type E2ETestResult } from '@e2e-tests/utils';
8 +import { describe, it, expect, beforeAll } from 'bun:test';
9 +
10 +e2e(import.meta.url, {
11 + nodeVersions: [
12 + // may throw ERR_REQUIRE_ESM
13 + '20.18.0',
14 + // supports ESM by default
15 + '20.19.0',
16 + '22.12.0',
17 + ],
18 + defineTests: ({ runFixture }) => {
19 + let result: E2ETestResult;
20 +
21 + beforeAll(async () => {
22 + result = await runFixture('fixtures/test.cjs');
23 + });
24 +
25 + describe('CommonJS compatibility', () => {
26 + it('exits successfully', () => {
27 + expect(result.exitCode).toBe(0);
28 + });
29 +
30 + it('require() succeeds', () => {
31 + expect(result.stdout).toContain('Test 1 passed: require() succeeded');
32 + });
33 +
34 + it('exports Composio class', () => {
35 + expect(result.stdout).toContain('Test 2 passed: Composio class is exported');
36 + });
37 +
38 + it('exports OpenAIProvider class', () => {
39 + expect(result.stdout).toContain('Test 3 passed: OpenAIProvider class is exported');
40 + });
41 +
42 + it('instantiates OpenAIProvider successfully', () => {
43 + expect(result.stdout).toContain('Test 4 passed: OpenAIProvider instantiated successfully');
44 + });
45 +
46 + it('exports AuthScheme', () => {
47 + expect(result.stdout).toContain('Test 5 passed: AuthScheme is exported');
48 + });
49 +
50 + it('exports Error classes', () => {
51 + expect(result.stdout).toContain('Test 6 passed: Error classes are exported');
52 + });
53 +
54 + it('exports jsonSchemaToZodSchema', () => {
55 + expect(result.stdout).toContain('Test 7 passed: jsonSchemaToZodSchema is exported');
56 + });
57 +
58 + it('exports constants namespace', () => {
59 + expect(result.stdout).toContain('Test 8 passed: constants namespace is exported');
60 + });
61 +
62 + it('exports logger', () => {
63 + expect(result.stdout).toContain('Test 9 passed: logger is exported');
64 + });
65 +
66 + it('completes all tests', () => {
67 + expect(result.stdout).toContain('All CommonJS compatibility tests passed!');
68 + });
69 + });
70 + },
71 +});
ts/e2e-tests/runtimes/node/cjs-basic/e2e.ts deleted
-47
@@ -1,47 +0,0 @@
1 -/**
2 - * CommonJS compatibility e2e test
3 - *
4 - * Verifies that @composio/core can be imported using require() in Node.js.
5 - */
6 -
7 -import { e2e } from '@e2e-tests/utils';
8 -
9 -await e2e(import.meta.url, {
10 - nodeVersions: [
11 - // may throw ERR_REQUIRE_ESM
12 - '20.18.0',
13 - // supports ESM by default
14 - '20.19.0',
15 - '22.12.0',
16 - ],
17 - fixture: 'fixtures/test.cjs',
18 - onTest: (result) => {
19 - if (result.exitCode !== 0) {
20 - console.error('Test fixture failed');
21 - console.error('stderr:', result.stderr);
22 - throw new Error(`Test failed with exit code ${result.exitCode}`);
23 - }
24 -
25 - // Verify expected output from test.cjs
26 - const expectedOutputs = [
27 - 'Test 1 passed: require() succeeded',
28 - 'Test 2 passed: Composio class is exported',
29 - 'Test 3 passed: OpenAIProvider class is exported',
30 - 'Test 4 passed: OpenAIProvider instantiated successfully',
31 - 'Test 5 passed: AuthScheme is exported',
32 - 'Test 6 passed: Error classes are exported',
33 - 'Test 7 passed: jsonSchemaToZodSchema is exported',
34 - 'Test 8 passed: constants namespace is exported',
35 - 'Test 9 passed: logger is exported',
36 - 'All CommonJS compatibility tests passed!',
37 - ];
38 -
39 - for (const expected of expectedOutputs) {
40 - if (!result.stdout.includes(expected)) {
41 - throw new Error(`Expected output not found: "${expected}"`);
42 - }
43 - }
44 -
45 - console.log('Test fixture passed with expected output');
46 - },
47 -});
ts/e2e-tests/runtimes/node/cjs-basic/package.json
+4 -3
@@ -1,11 +1,12 @@
1 {
2 - "name": "@test-e2e/node-cjs-basic",
2 + "name": "@e2e-tests/node-cjs-basic",
3 "version": "0.0.0",
4 "private": true,
5 "type": "module",
6 "scripts": {
7 - "test:e2e": "bun e2e.ts",
8 - "test:e2e:node": "bun e2e.ts"
7 + "typecheck": "tsc --noEmit",
8 + "test:e2e": "bun test e2e.test.ts",
9 + "test:e2e:node": "bun test e2e.test.ts"
10 },
11 "devDependencies": {
12 "@composio/core": "workspace:*",
ts/e2e-tests/runtimes/node/cjs-basic/tsconfig.json
+1 -1
@@ -8,5 +8,5 @@
8 "skipLibCheck": true,
9 "noEmit": true
10 },
11 - "include": ["e2e.ts"]
11 + "include": ["e2e.test.ts"]
12 }
ts/e2e-tests/runtimes/node/esm-basic/e2e.test.ts new
+75
@@ -0,0 +1,75 @@
1 +/**
2 + * ESM compatibility e2e test
3 + *
4 + * Verifies that @composio/core can be imported using ESM import syntax in Node.js.
5 + */
6 +
7 +import { e2e, type E2ETestResult } from '@e2e-tests/utils';
8 +import { describe, it, expect, beforeAll } from 'bun:test';
9 +
10 +e2e(import.meta.url, {
11 + nodeVersions: [
12 + // may throw ERR_REQUIRE_ESM
13 + '20.18.0',
14 + // supports ESM by default
15 + '20.19.0',
16 + '22.12.0',
17 + ],
18 + defineTests: ({ runFixture }) => {
19 + let result: E2ETestResult;
20 +
21 + beforeAll(async () => {
22 + result = await runFixture('fixtures/test.mjs');
23 + });
24 +
25 + describe('ESM compatibility', () => {
26 + it('exits successfully', () => {
27 + expect(result.exitCode).toBe(0);
28 + });
29 +
30 + it('import() succeeds', () => {
31 + expect(result.stdout).toContain('Test 1 passed: import() succeeded');
32 + });
33 +
34 + it('exports Composio class', () => {
35 + expect(result.stdout).toContain('Test 2 passed: Composio class is exported');
36 + });
37 +
38 + it('exports OpenAIProvider class', () => {
39 + expect(result.stdout).toContain('Test 3 passed: OpenAIProvider class is exported');
40 + });
41 +
42 + it('instantiates OpenAIProvider successfully', () => {
43 + expect(result.stdout).toContain('Test 4 passed: OpenAIProvider instantiated successfully');
44 + });
45 +
46 + it('exports AuthScheme', () => {
47 + expect(result.stdout).toContain('Test 5 passed: AuthScheme is exported');
48 + });
49 +
50 + it('exports Error classes', () => {
51 + expect(result.stdout).toContain('Test 6 passed: Error classes are exported');
52 + });
53 +
54 + it('exports jsonSchemaToZodSchema', () => {
55 + expect(result.stdout).toContain('Test 7 passed: jsonSchemaToZodSchema is exported');
56 + });
57 +
58 + it('exports constants namespace', () => {
59 + expect(result.stdout).toContain('Test 8 passed: constants namespace is exported');
60 + });
61 +
62 + it('exports logger', () => {
63 + expect(result.stdout).toContain('Test 9 passed: logger is exported');
64 + });
65 +
66 + it('supports static import syntax', () => {
67 + expect(result.stdout).toContain('Test 10 passed: Static import syntax works');
68 + });
69 +
70 + it('completes all tests', () => {
71 + expect(result.stdout).toContain('All ESM compatibility tests passed!');
72 + });
73 + });
74 + },
75 +});
ts/e2e-tests/runtimes/node/esm-basic/e2e.ts deleted
-48
@@ -1,48 +0,0 @@
1 -/**
2 - * ESM compatibility e2e test
3 - *
4 - * Verifies that @composio/core can be imported using ESM import syntax in Node.js.
5 - */
6 -
7 -import { e2e } from '@e2e-tests/utils';
8 -
9 -await e2e(import.meta.url, {
10 - nodeVersions: [
11 - // may throw ERR_REQUIRE_ESM
12 - '20.18.0',
13 - // supports ESM by default
14 - '20.19.0',
15 - '22.12.0',
16 - ],
17 - fixture: 'fixtures/test.mjs',
18 - onTest: (result) => {
19 - if (result.exitCode !== 0) {
20 - console.error('Test fixture failed');
21 - console.error('stderr:', result.stderr);
22 - throw new Error(`Test failed with exit code ${result.exitCode}`);
23 - }
24 -
25 - // Verify expected output from test.mjs
26 - const expectedOutputs = [
27 - 'Test 1 passed: import() succeeded',
28 - 'Test 2 passed: Composio class is exported',
29 - 'Test 3 passed: OpenAIProvider class is exported',
30 - 'Test 4 passed: OpenAIProvider instantiated successfully',
31 - 'Test 5 passed: AuthScheme is exported',
32 - 'Test 6 passed: Error classes are exported',
33 - 'Test 7 passed: jsonSchemaToZodSchema is exported',
34 - 'Test 8 passed: constants namespace is exported',
35 - 'Test 9 passed: logger is exported',
36 - 'Test 10 passed: Static import syntax works',
37 - 'All ESM compatibility tests passed!',
38 - ];
39 -
40 - for (const expected of expectedOutputs) {
41 - if (!result.stdout.includes(expected)) {
42 - throw new Error(`Expected output not found: "${expected}"`);
43 - }
44 - }
45 -
46 - console.log('Test fixture passed with expected output');
47 - },
48 -});
ts/e2e-tests/runtimes/node/esm-basic/package.json
+4 -3
@@ -1,11 +1,12 @@
1 {
2 - "name": "@test-e2e/node-esm-basic",
2 + "name": "@e2e-tests/node-esm-basic",
3 "version": "0.0.0",
4 "private": true,
5 "type": "module",
6 "scripts": {
7 - "test:e2e": "bun e2e.ts",
8 - "test:e2e:node": "bun e2e.ts"
7 + "typecheck": "tsc --noEmit",
8 + "test:e2e": "bun test e2e.test.ts",
9 + "test:e2e:node": "bun test e2e.test.ts"
10 },
11 "devDependencies": {
12 "@composio/core": "workspace:*",
ts/e2e-tests/runtimes/node/esm-basic/tsconfig.json
+1 -1
@@ -8,5 +8,5 @@
8 "skipLibCheck": true,
9 "noEmit": true
10 },
11 - "include": ["e2e.ts"]
11 + "include": ["e2e.test.ts"]
12 }
ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.test.ts new
+65
@@ -0,0 +1,65 @@
1 +/**
2 + * OpenAI v6 + Zod v4 compatibility e2e test
3 + *
4 + * Verifies that @composio/core works correctly with openai@6 and zod@4,
5 + * specifically testing the fix for https://github.com/ComposioHQ/composio/issues/2336
6 + */
7 +
8 +import { e2e, type E2ETestResult } from '@e2e-tests/utils';
9 +import { describe, it, expect, beforeAll } from 'bun:test';
10 +
11 +declare module 'bun' {
12 + interface Env {
13 + COMPOSIO_API_KEY: string;
14 + }
15 +}
16 +
17 +e2e(import.meta.url, {
18 + nodeVersions: ['20.19.0', '22.12.0'],
19 + env: {
20 + COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
21 + },
22 + defineTests: ({ runCmd, runFixture }) => {
23 + let setupResult: E2ETestResult;
24 + let testResult: E2ETestResult;
25 +
26 + beforeAll(async () => {
27 + // Run npm install first
28 + setupResult = await runCmd('npm --prefix fixtures install --legacy-peer-deps');
29 + // Then run the test fixture
30 + testResult = await runFixture('fixtures/index.mjs');
31 + });
32 +
33 + describe('setup', () => {
34 + it('npm install completes successfully', () => {
35 + expect(setupResult.exitCode).toBe(0);
36 + });
37 + });
38 +
39 + describe('OpenAI v6 + Zod v4 compatibility', () => {
40 + it('exits successfully', () => {
41 + expect(testResult.exitCode).toBe(0);
42 + });
43 +
44 + it('zod@4 works', () => {
45 + expect(testResult.stdout).toContain('zod@4 works');
46 + });
47 +
48 + it('openai@5 works', () => {
49 + expect(testResult.stdout).toContain('openai@5 works');
50 + });
51 +
52 + it('@composio/core works', () => {
53 + expect(testResult.stdout).toContain('@composio/core works');
54 + });
55 +
56 + it('wrapTool works', () => {
57 + expect(testResult.stdout).toContain('wrapTool works');
58 + });
59 +
60 + it('all packages work together', () => {
61 + expect(testResult.stdout).toContain('All packages work together!');
62 + });
63 + });
64 + },
65 +});
ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.ts deleted
-55
@@ -1,55 +0,0 @@
1 -/**
2 - * OpenAI v6 + Zod v4 compatibility e2e test
3 - *
4 - * Verifies that @composio/core works correctly with openai@6 and zod@4,
5 - * specifically testing the fix for https://github.com/ComposioHQ/composio/issues/2336
6 - */
7 -
8 -import { e2e } from '@e2e-tests/utils';
9 -
10 -declare module "bun" {
11 - interface Env {
12 - COMPOSIO_API_KEY: string;
13 - }
14 -}
15 -
16 -await e2e(import.meta.url, {
17 - nodeVersions: ['20.19.0', '22.12.0'],
18 - setup: 'npm --prefix fixtures install --legacy-peer-deps',
19 - fixture: 'fixtures/index.mjs',
20 - env: {
21 - COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
22 - },
23 - onSetup: (result) => {
24 - if (result.exitCode !== 0) {
25 - console.error('npm install failed');
26 - console.error('stderr:', result.stderr);
27 - throw new Error(`Setup failed with exit code ${result.exitCode}`);
28 - }
29 - console.log('npm install completed successfully');
30 - },
31 - onTest: (result) => {
32 - if (result.exitCode !== 0) {
33 - console.error('Test fixture failed');
34 - console.error('stderr:', result.stderr);
35 - throw new Error(`Test failed with exit code ${result.exitCode}`);
36 - }
37 -
38 - // Verify expected output from fixtures/index.mjs
39 - const expectedOutputs = [
40 - 'zod@4 works',
41 - 'openai@5 works',
42 - '@composio/core works',
43 - 'wrapTool works',
44 - 'All packages work together!',
45 - ];
46 -
47 - for (const expected of expectedOutputs) {
48 - if (!result.stdout.includes(expected)) {
49 - throw new Error(`Expected output not found: "${expected}"`);
50 - }
51 - }
52 -
53 - console.log('Test fixture passed with expected output');
54 - },
55 -});
ts/e2e-tests/runtimes/node/openai-zod4-compat/package.json
+4 -3
@@ -1,11 +1,12 @@
1 {
2 - "name": "@test-e2e/node-openai-zod4-compat",
2 + "name": "@e2e-tests/node-openai-zod4-compat",
3 "version": "0.0.0",
4 "private": true,
5 "type": "module",
6 "scripts": {
7 - "test:e2e": "bun e2e.ts",
8 - "test:e2e:node": "bun e2e.ts"
7 + "typecheck": "tsc --noEmit",
8 + "test:e2e": "bun test e2e.test.ts",
9 + "test:e2e:node": "bun test e2e.test.ts"
10 },
11 "devDependencies": {
12 "@e2e-tests/utils": "workspace:*"
ts/e2e-tests/runtimes/node/openai-zod4-compat/tsconfig.json
+1 -1
@@ -8,5 +8,5 @@
8 "skipLibCheck": true,
9 "noEmit": true
10 },
11 - "include": ["e2e.ts"]
11 + "include": ["e2e.test.ts"]
12 }
ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.test.ts new
+53
@@ -0,0 +1,53 @@
1 +/**
2 + * TypeScript .mjs import resolution e2e test
3 + *
4 + * Verifies that generated TypeScript files with .mjs imports
5 + * can be compiled successfully with moduleResolution: "nodenext".
6 + *
7 + * Requires COMPOSIO_API_KEY environment variable to be set.
8 + */
9 +
10 +import { e2e, type E2ETestResult } from '@e2e-tests/utils';
11 +import { describe, it, expect, beforeAll } from 'bun:test';
12 +
13 +declare module 'bun' {
14 + interface Env {
15 + COMPOSIO_API_KEY: string;
16 + }
17 +}
18 +
19 +e2e(import.meta.url, {
20 + nodeVersions: ['current'],
21 + env: {
22 + COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
23 + },
24 + defineTests: ({ runFixture }) => {
25 + let result: E2ETestResult;
26 +
27 + beforeAll(async () => {
28 + result = await runFixture('fixtures/index.mjs');
29 + }, 300_000);
30 +
31 + describe('TypeScript .mjs import resolution', () => {
32 + it('exits successfully', () => {
33 + expect(result.exitCode).toBe(0);
34 + });
35 +
36 + it('composio ts generate succeeds', () => {
37 + expect(result.stdout).toContain('Test 1 passed: composio ts generate succeeded');
38 + });
39 +
40 + it('generated files exist', () => {
41 + expect(result.stdout).toContain('Test 2 passed: Generated files exist');
42 + });
43 +
44 + it('TypeScript compilation succeeds', () => {
45 + expect(result.stdout).toContain('Test 3 passed: TypeScript compilation succeeded');
46 + });
47 +
48 + it('completes all tests', () => {
49 + expect(result.stdout).toContain('All tests passed!');
50 + });
51 + });
52 + },
53 +});
ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.ts deleted
-47
@@ -1,47 +0,0 @@
1 -/**
2 - * TypeScript .mjs import resolution e2e test
3 - *
4 - * Verifies that generated TypeScript files with .mjs imports
5 - * can be compiled successfully with moduleResolution: "nodenext".
6 - *
7 - * Requires COMPOSIO_API_KEY environment variable to be set.
8 - */
9 -
10 -import { e2e } from '@e2e-tests/utils';
11 -
12 -declare module "bun" {
13 - interface Env {
14 - COMPOSIO_API_KEY: string;
15 - }
16 -}
17 -
18 -await e2e(import.meta.url, {
19 - nodeVersions: ['20.19.0', '22.12.0'],
20 - fixture: 'test.mjs',
21 - env: {
22 - COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
23 - },
24 - onTest: (result) => {
25 - if (result.exitCode !== 0) {
26 - console.error('Test fixture failed');
27 - console.error('stderr:', result.stderr);
28 - throw new Error(`Test failed with exit code ${result.exitCode}`);
29 - }
30 -
31 - // Verify expected output from test.mjs
32 - const expectedOutputs = [
33 - 'Test 1 passed: composio ts generate succeeded',
34 - 'Test 2 passed: Generated files exist',
35 - 'Test 3 passed: TypeScript compilation succeeded',
36 - 'All tests passed!',
37 - ];
38 -
39 - for (const expected of expectedOutputs) {
40 - if (!result.stdout.includes(expected)) {
41 - throw new Error(`Expected output not found: "${expected}"`);
42 - }
43 - }
44 -
45 - console.log('Test fixture passed with expected output');
46 - },
47 -});
ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/fixtures/index.mjs renamed
ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/fixtures/tsconfig.json new
+14
@@ -0,0 +1,14 @@
1 +{
2 + "$schema": "https://json.schemastore.org/tsconfig",
3 + "compilerOptions": {
4 + "target": "es2022",
5 + "module": "nodenext",
6 + "moduleResolution": "nodenext",
7 + "strict": true,
8 + "skipLibCheck": true,
9 + "noEmit": true
10 + },
11 + "include": [
12 + "generated"
13 + ]
14 +}
ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/package.json
+4 -3
@@ -1,11 +1,12 @@
1 {
2 - "name": "@test-e2e/node-typescript-mjs-import-nodenext",
2 + "name": "@e2e-tests/node-typescript-mjs-import-nodenext",
3 "version": "0.0.0",
4 "private": true,
5 "type": "module",
6 "scripts": {
7 - "test:e2e": "bun e2e.ts",
8 - "test:e2e:node": "bun e2e.ts"
7 + "typecheck": "tsc --noEmit",
8 + "test:e2e": "bun test e2e.test.ts",
9 + "test:e2e:node": "bun test e2e.test.ts"
10 },
11 "devDependencies": {
12 "@composio/cli": "workspace:*",
ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/tsconfig.json
+9 -9
@@ -1,14 +1,14 @@
1 {
2 + "$schema": "https://json.schemastore.org/tsconfig",
3 "compilerOptions": {
4 "target": "es2022",
4 - "module": "nodenext",
5 - "moduleResolution": "nodenext",
6 - "declaration": true,
7 - "outDir": "./dist",
8 - "rootDir": "./generated",
5 + "module": "esnext",
6 + "moduleResolution": "bundler",
7 "strict": true,
10 - "esModuleInterop": true,
11 - "skipLibCheck": true
8 + "skipLibCheck": true,
9 + "noEmit": true
10 },
13 - "include": ["generated"]
14 -}
11 + "include": [
12 + "e2e.test.ts"
13 + ]
14 +}
\ No newline at end of file