Skip to content

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

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

jkomyno6aa99bc80fb3
diff --git a/package.json b/package.json
index cdd6dd05e..95c412d5c 100644
--- a/package.json
+++ b/package.json
@@ -13,10 +13,10 @@
"build": "turbo build",
"build:bin": "turbo build:bin --filter=./ts/packages/cli",
"build:packages": "turbo build --filter=./ts/packages/**",
- "test": "turbo test --filter=./ts/packages/** --filter=!@test-e2e/*",
- "test:e2e": "turbo test:e2e --filter='@test-e2e/*'",
- "test:e2e:node": "turbo test:e2e:node --filter='@test-e2e/node-*'",
- "test:e2e:cloudflare": "turbo test:e2e:cloudflare --filter='@test-e2e/cf-*'",
+ "test": "turbo test --filter=./ts/packages/** --filter=!@e2e-tests/*",
+ "test:e2e": "turbo test:e2e --filter='@e2e-tests/*'",
+ "test:e2e:node": "turbo test:e2e:node --filter='@e2e-tests/node-*'",
+ "test:e2e:cloudflare": "turbo test:e2e:cloudflare --filter='@e2e-tests/cf-*'",
"test:ui": "vitest --ui",
"typecheck": "turbo typecheck --filter=./ts/packages/**",
"lint": "eslint ts/packages --ext .ts,.tsx",
diff --git a/ts/e2e-tests/README.md b/ts/e2e-tests/README.md
index 77be88889..ef082bed5 100644
--- a/ts/e2e-tests/README.md
+++ b/ts/e2e-tests/README.md
@@ -60,7 +60,7 @@ pnpm test:e2e:cloudflare
### Node.js Runtime Tests
1. Create a new directory under `runtimes/node/` (e.g., `runtimes/node/my-test`)
-2. Add a `package.json` with name `@test-e2e/node-my-test`
+2. Add a `package.json` with name `@e2e-tests/node-my-test`
3. Add `test:e2e` and `test:e2e:node` scripts
4. Create an `e2e.ts` file with inline configuration:
@@ -86,6 +86,6 @@ await e2e(import.meta.url, {
### Cloudflare Runtime Tests
1. Create a new directory under `runtimes/cloudflare/` (e.g., `runtimes/cloudflare/my-test`)
-2. Add a `package.json` with name `@test-e2e/cf-my-test`
+2. Add a `package.json` with name `@e2e-tests/cf-my-test`
3. Add `test:e2e` and `test:e2e:cloudflare` scripts
4. Configure vitest with `@cloudflare/vitest-pool-workers`
diff --git a/ts/e2e-tests/_utils/Dockerfile.node b/ts/e2e-tests/_utils/Dockerfile.node
index 879ae1411..8c8bba1c9 100644
--- a/ts/e2e-tests/_utils/Dockerfile.node
+++ b/ts/e2e-tests/_utils/Dockerfile.node
@@ -1,5 +1,6 @@
+# syntax=docker/dockerfile:1
# Reusable Dockerfile for Node.js e2e tests
-# 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 .
+# Usage: docker build -f Dockerfile.node --build-arg NODE_VERSION=20.19.0 -t test-name .
#
# Uses official node:slim images. For multi-version testing, run the build/run
# multiple times with different NODE_VERSION values from the shell script.
@@ -14,36 +15,40 @@ ENV PATH="$BUN_INSTALL/bin:$PNPM_HOME:$PATH"
WORKDIR /app
-COPY package.json \
- .bun-version \
- ./
-
-RUN apt update -y && \
- apt install -y curl unzip
-
-# Install corepack (for pnpm) and bun
-RUN npm i -g corepack@latest \
- && corepack enable \
- && curl -fsSL https://bun.com/install | BUN_INSTALL=/usr/local bash \
- && bun --version
-
-# Copy pnpm workspace files
-COPY pnpm-lock.yaml \
- pnpm-workspace.yaml \
- .pnpmfile.cjs \
- tsconfig.base.json \
- tsdown.config.base.ts \
- ./
+# Install system dependencies with cache mounts
+RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
+ apt-get update && \
+ apt-get install -y --no-install-recommends ca-certificates curl unzip && \
+ rm -rf /var/lib/apt/lists/*
-# Copy all ts/packages (pre-built)
-COPY ts/packages/ ./ts/packages/
+# Install corepack (for pnpm) with npm cache mount
+RUN --mount=type=cache,target=/root/.npm \
+ npm i -g corepack@latest && \
+ corepack enable
+
+# Install bun (version from .bun-version)
+COPY .bun-version ./
+RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash -s "bun-v$(cat .bun-version)" && \
+ bun --version
+
+# Copy lockfile first for optimal layer caching
+COPY pnpm-lock.yaml ./
+
+# Copy workspace configuration files
+COPY package.json \
+ pnpm-workspace.yaml \
+ .pnpmfile.cjs \
+ tsconfig.base.json \
+ tsdown.config.base.ts \
+ ./
-# Copy pre-install scripts
+# Copy pre-install scripts (rarely change)
COPY ts/scripts/pre-install.sh ./ts/scripts/pre-install.sh
COPY ts/scripts/pre-install/ ./ts/scripts/pre-install/
-# Copy e2e tests
-COPY ts/e2e-tests/ ./ts/e2e-tests/
+# Copy all ts/packages (pre-built)
+COPY ts/packages/ ./ts/packages/
# Install dependencies using pnpm
# Note: We intentionally don't use --mount=type=cache for the pnpm store here
@@ -54,13 +59,16 @@ RUN pnpm install --frozen-lockfile
# This is a simplified version of ts/packages/cli/scripts/build-binary.ts + install-binary.ts
WORKDIR /app/ts/packages/cli
RUN bun build ./src/bin.ts \
- --env DEBUG_OVERRIDE_* \
- --compile \
- --production \
- --outfile /usr/local/bin/composio
+ --env DEBUG_OVERRIDE_* \
+ --compile \
+ --production \
+ --outfile /usr/local/bin/composio
WORKDIR /app
+# Copy e2e tests last (changes frequently)
+COPY ts/e2e-tests/ ./ts/e2e-tests/
+
RUN chown -R node:node /app
# Pre-create Composio CLI cache directory to work around Bun issue #7967
diff --git a/ts/e2e-tests/_utils/package.json b/ts/e2e-tests/_utils/package.json
index 5399ecb09..95a27a947 100644
--- a/ts/e2e-tests/_utils/package.json
+++ b/ts/e2e-tests/_utils/package.json
@@ -13,6 +13,10 @@
}
}
},
+ "scripts": {
+ "docker:build": "bun run scripts/docker-build.ts",
+ "docker:clean": "bun run scripts/docker-clean.ts"
+ },
"devDependencies": {
"typescript": "catalog:"
}
diff --git a/ts/e2e-tests/_utils/scripts/docker-build.ts b/ts/e2e-tests/_utils/scripts/docker-build.ts
new file mode 100644
index 000000000..bb2b62b70
--- /dev/null
+++ b/ts/e2e-tests/_utils/scripts/docker-build.ts
@@ -0,0 +1,96 @@
+#!/usr/bin/env bun
+/**
+ * Builds Docker images for all well-known Node.js versions used by e2e tests.
+ * This includes versions from WELL_KNOWN_NODE_VERSIONS and the current runtime version.
+ */
+
+import { $ } from 'bun';
+import { resolve, dirname } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { WELL_KNOWN_NODE_VERSIONS } from '../src/const';
+
+const __dirname = dirname(fileURLToPath(import.meta.url));
+
+function getRepoRoot(): string {
+ // From scripts/ to repo root: scripts -> _utils -> e2e-tests -> ts -> composio
+ return resolve(__dirname, '../../../..');
+}
+
+function imageTagForNodeVersion(nodeVersion: string): string {
+ return `composio-e2e-node:${nodeVersion}`;
+}
+
+function defaultLabels(nodeVersion: string): Record<string, string> {
+ return {
+ 'composio.e2e': 'true',
+ 'composio.runtime': 'node',
+ 'composio.node_version': nodeVersion,
+ };
+}
+
+async function buildImage(nodeVersion: string, repoRoot: string): Promise<boolean> {
+ const dockerfilePath = resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.node');
+ const imageTag = imageTagForNodeVersion(nodeVersion);
+ const labels = defaultLabels(nodeVersion);
+ const labelArgs = Object.entries(labels)
+ .map(([k, v]) => `--label=${k}=${v}`)
+ .join(' ');
+
+ console.log(`\nBuilding image for Node.js ${nodeVersion}...`);
+
+ const result = await $`docker build -f ${dockerfilePath} --build-arg NODE_VERSION=${nodeVersion} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`
+ .cwd(repoRoot)
+ .nothrow();
+
+ if (result.exitCode !== 0) {
+ console.error(` Failed to build ${imageTag}:`);
+ console.error(result.stderr.toString() || result.stdout.toString());
+ return false;
+ }
+
+ console.log(` Built ${imageTag}`);
+ return true;
+}
+
+async function main() {
+ const repoRoot = getRepoRoot();
+ const currentNodeVersion = process.versions.node;
+
+ // Collect all unique Node versions to build
+ const versions = new Set<string>();
+
+ for (const version of WELL_KNOWN_NODE_VERSIONS) {
+ if (version === 'current') {
+ versions.add(currentNodeVersion);
+ } else {
+ versions.add(version);
+ }
+ }
+
+ const versionList = Array.from(versions);
+ console.log('Building Docker images for Node.js versions:');
+ for (const v of versionList) {
+ const isCurrent = v === currentNodeVersion ? ' (current)' : '';
+ console.log(` - ${v}${isCurrent}`);
+ }
+
+ let failed = 0;
+ for (const version of versionList) {
+ const success = await buildImage(version, repoRoot);
+ if (!success) {
+ failed++;
+ }
+ }
+
+ console.log('\n---');
+ console.log(`Built ${versionList.length - failed}/${versionList.length} images.`);
+
+ if (failed > 0) {
+ process.exit(1);
+ }
+}
+
+main().catch((err) => {
+ console.error('Error:', err);
+ process.exit(1);
+});
diff --git a/ts/e2e-tests/_utils/scripts/docker-clean.ts b/ts/e2e-tests/_utils/scripts/docker-clean.ts
new file mode 100644
index 000000000..42123077a
--- /dev/null
+++ b/ts/e2e-tests/_utils/scripts/docker-clean.ts
@@ -0,0 +1,61 @@
+#!/usr/bin/env bun
+/**
+ * Removes all Docker images used by the Node.js e2e tests.
+ * Images are identified by the label `composio.e2e=true` and `composio.runtime=node`.
+ */
+
+import { $ } from 'bun';
+
+async function main() {
+ console.log('Finding e2e Node.js Docker images...');
+
+ // Find all images with the e2e labels
+ const result = await $`docker images --filter label=composio.e2e=true --filter label=composio.runtime=node --format {{.Repository}}:{{.Tag}}`
+ .nothrow()
+ .quiet();
+
+ if (result.exitCode !== 0) {
+ console.error('Failed to list Docker images:', result.stderr.toString());
+ process.exit(1);
+ }
+
+ const images = result.stdout
+ .toString()
+ .trim()
+ .split('\n')
+ .filter((img) => img.length > 0 && !img.includes('<none>'));
+
+ if (images.length === 0) {
+ console.log('No e2e Node.js Docker images found.');
+ return;
+ }
+
+ console.log(`Found ${images.length} image(s) to remove:`);
+ for (const img of images) {
+ console.log(` - ${img}`);
+ }
+
+ console.log('\nRemoving images...');
+
+ // Remove images one by one to safely handle each image name
+ let removeFailures = 0;
+ for (const img of images) {
+ const removeResult = await $`docker rmi ${img}`.nothrow().quiet();
+ if (removeResult.exitCode !== 0) {
+ console.error(` Failed to remove ${img}:`, removeResult.stderr.toString());
+ removeFailures++;
+ }
+ }
+
+ if (removeFailures > 0) {
+ console.error(`Failed to remove ${removeFailures} image(s).`);
+ process.exit(1);
+ }
+
+ console.log('Done.');
+}
+
+main().catch((err) => {
+ console.error('Error:', err);
+ process.exit(1);
+});
diff --git a/ts/e2e-tests/_utils/src/config.ts b/ts/e2e-tests/_utils/src/config.ts
index 8a6f6e5ff..11992dd9f 100644
--- a/ts/e2e-tests/_utils/src/config.ts
+++ b/ts/e2e-tests/_utils/src/config.ts
@@ -1,6 +1,7 @@
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
-import type { NodeVersion } from './types';
+import process from 'node:process';
+import type { NodeVersionMeta, NodeVersionFromUser } from './types';
/**
* Get the repository root path.
@@ -20,17 +21,29 @@ export function getRepoRoot(): string {
* 2. Provided nodeVersions from config
* 3. Current Node.js runtime version
*/
-export function resolveNodeVersions(
- configNodeVersions?: readonly NodeVersion[]
-): readonly NodeVersion[] {
+export function resolveNodeVersionMetaList(
+ configNodeVersions?: readonly NodeVersionFromUser[]
+): readonly NodeVersionMeta[] {
const envVersion = process.env.COMPOSIO_E2E_NODE_VERSION;
if (envVersion) {
- return [envVersion];
+ return [{ kind: 'overridden', value: envVersion }];
}
- if (configNodeVersions && configNodeVersions.length > 0) {
- return configNodeVersions;
+ const currentNodeVersion = process.versions.node;
+
+ if (configNodeVersions === undefined) {
+ return [{ kind: 'current', value: currentNodeVersion }];
}
- return [process.versions.node];
+ const distinctNodeVersions = Array.from(
+ new Set(
+ configNodeVersions
+ .map((v => v === 'current'
+ ? { kind: 'current', value: currentNodeVersion } as const
+ : { kind: 'static', value: v } as const)
+ )
+ )
+ );
+
+ return distinctNodeVersions;
}
diff --git a/ts/e2e-tests/_utils/src/const.ts b/ts/e2e-tests/_utils/src/const.ts
new file mode 100644
index 000000000..609fb3e1d
--- /dev/null
+++ b/ts/e2e-tests/_utils/src/const.ts
@@ -0,0 +1 @@
+export const WELL_KNOWN_NODE_VERSIONS = ['20.18.0', '20.19.0', '22.12.0', 'current'] as const;
diff --git a/ts/e2e-tests/_utils/src/e2e.ts b/ts/e2e-tests/_utils/src/e2e.ts
index bbc52b1be..7f99e6fcf 100644
--- a/ts/e2e-tests/_utils/src/e2e.ts
+++ b/ts/e2e-tests/_utils/src/e2e.ts
@@ -36,25 +36,46 @@ function inferCwd(importMetaUrl: string, repoRoot: string): string {
}
/**
- * Run an e2e test with inline configuration.
+ * Run e2e tests with full bun:test capabilities.
*
- * This is the main entry point for e2e tests. It automatically infers
- * the working directory and suite name from the caller's location.
+ * This function sets up bun:test describe/it blocks internally.
+ * When the test file is run via `bun test`, the full bun:test API
+ * is available in your defineTests callback.
*
* @param importMetaUrl - Pass `import.meta.url` from your test file
- * @param config - Test configuration
+ * @param config - Test configuration with defineTests callback
*
* @example
* ```typescript
- * await e2e(import.meta.url, { fixture: 'fixtures/test.mjs' });
+ * // e2e.test.ts
+ * import { e2e } from '@e2e-tests/utils';
+ * import type { E2ETestResult } from '@e2e-tests/utils';
+ *
+ * e2e(import.meta.url, {
+ * nodeVersions: ['20.19.0', '22.12.0'],
+ * env: { COMPOSIO_API_KEY: process.env.COMPOSIO_API_KEY },
+ * defineTests: ({ describe, it, expect, beforeAll, runFixture }) => {
+ * let result: E2ETestResult;
+ *
+ * beforeAll(async () => {
+ * result = await runFixture('fixtures/test.mjs');
+ * }, 300_000);
+ *
+ * describe('output', () => {
+ * it('exits successfully', () => {
+ * expect(result.exitCode).toBe(0);
+ * });
+ * });
+ * },
+ * });
* ```
*/
-export async function e2e(importMetaUrl: string, config: E2EConfig): Promise<never> {
+export function e2e(importMetaUrl: string, config: E2EConfig): void {
validateImportMetaUrl(importMetaUrl);
const repoRoot = getRepoRoot();
const cwd = inferCwd(importMetaUrl, repoRoot);
const suiteName = cwd.split('/').pop() ?? 'unknown';
- return runE2E({ ...config, cwd, suiteName });
+ runE2E({ ...config, cwd, suiteName });
}
diff --git a/ts/e2e-tests/_utils/src/image-lifecycle.ts b/ts/e2e-tests/_utils/src/image-lifecycle.ts
index 75dd30521..5d3735884 100644
--- a/ts/e2e-tests/_utils/src/image-lifecycle.ts
+++ b/ts/e2e-tests/_utils/src/image-lifecycle.ts
@@ -1,4 +1,4 @@
-import { spawn } from 'node:child_process';
+import { $ } from 'bun';
import { resolve } from 'node:path';
import { getRepoRoot } from './config';
@@ -56,6 +56,14 @@ export interface CheckDockerOptions {
repoRoot?: string;
}
+/**
+ * Escapes a shell argument for safe use in Bun shell raw strings.
+ */
+function escapeShellArg(arg: string): string {
+ // Single-quote the arg and escape any embedded single quotes
+ return `'${arg.replace(/'/g, "'\\''")}'`;
+}
+
/**
* Creates default Docker labels for e2e images.
*/
@@ -71,7 +79,7 @@ function defaultLabels(nodeVersion?: string): Record<string, string> {
}
/**
- * Converts labels object to Docker CLI arguments.
+ * Converts labels object to Docker CLI arguments array.
*/
function labelsToArgs(labels: Record<string, string> = {}): string[] {
const args: string[] = [];
@@ -82,36 +90,31 @@ function labelsToArgs(labels: Record<string, string> = {}): string[] {
}
/**
- * Executes a command and captures stdout/stderr.
+ * Executes a command and captures stdout/stderr using Bun shell.
*/
async function exec(cmd: string, args: string[], options: ExecOptions = {}): Promise<ExecResult> {
const { cwd, env } = options;
- const child = spawn(cmd, args, {
- cwd,
- env: env ? { ...process.env, ...env } : process.env,
- stdio: ['ignore', 'pipe', 'pipe'],
- });
-
- let stdout = '';
- let stderr = '';
+ const escapedArgs = args.map(escapeShellArg).join(' ');
- child.stdout.setEncoding('utf8');
- child.stderr.setEncoding('utf8');
+ let shell = $`${{ raw: cmd }} ${{ raw: escapedArgs }}`
+ .nothrow()
+ .quiet();
- child.stdout.on('data', (d: string) => {
- stdout += d;
- });
+ if (cwd) {
+ shell = shell.cwd(cwd);
+ }
- child.stderr.on('data', (d: string) => {
- stderr += d;
- });
+ if (env) {
+ shell = shell.env({ ...process.env, ...env });
+ }
- const code = await new Promise<number>((res, rej) => {
- child.on('error', rej);
- child.on('close', (exitCode) => res(exitCode ?? 1));
- });
+ const result = await shell;
- return { exitCode: code, stdout, stderr };
+ return {
+ exitCode: result.exitCode,
+ stdout: result.stdout.toString(),
+ stderr: result.stderr.toString(),
+ };
}
/**
@@ -145,7 +148,7 @@ export async function ensureNodeImage(
options: EnsureNodeImageOptions = {}
): Promise<string> {
if (!nodeVersion || typeof nodeVersion !== 'string') {
- throw new Error('ensureNodeImage(nodeVersion): nodeVersion must be a non-empty string');
+ throw new Error(`ensureNodeImage(${nodeVersion}): nodeVersion must be a non-empty string`);
}
const repoRoot = options.repoRoot ?? getRepoRoot();
diff --git a/ts/e2e-tests/_utils/src/index.ts b/ts/e2e-tests/_utils/src/index.ts
index 4964a7d72..028904a86 100644
--- a/ts/e2e-tests/_utils/src/index.ts
+++ b/ts/e2e-tests/_utils/src/index.ts
@@ -1,3 +1,3 @@
-export type { E2EConfig, E2ETestResult, E2EPhaseResults, E2EAssertionCallback } from './types';
+export type { E2EConfig, E2ETestResult, DefineTestsContext, NodeVersionMeta as NodeVersion } from './types';
export { e2e } from './e2e';
-export { checkDocker } from './image-lifecycle';
+export { sanitizeOutput } from './sanitize';
diff --git a/ts/e2e-tests/_utils/src/runner.ts b/ts/e2e-tests/_utils/src/runner.ts
index 0d60475c9..e703ef314 100644
--- a/ts/e2e-tests/_utils/src/runner.ts
+++ b/ts/e2e-tests/_utils/src/runner.ts
@@ -1,8 +1,7 @@
-import { writeFileSync, appendFileSync } from 'node:fs';
-import { resolve } from 'node:path';
-import type { E2EConfig, E2EPhaseResults, E2ETestResult } from './types';
-import { getRepoRoot, resolveNodeVersions } from './config';
-import { checkDocker, ensureNodeImage, runNodeContainer } from './image-lifecycle';
+import { describe, beforeAll } from 'bun:test';
+import type { E2EConfig, E2ETestResult, NodeVersionMeta } from './types';
+import { getRepoRoot, resolveNodeVersionMetaList } from './config';
+import { ensureNodeImage, runNodeContainer } from './image-lifecycle';
/**
* Environment variables to automatically pass through to Docker containers.
@@ -32,223 +31,77 @@ function buildContainerEnv(
}
/**
- * Initialize the DEBUG.log file with a header.
+ * Internal configuration for runE2E.
*/
-function initDebugLog(logPath: string, suiteName: string, nodeVersions: readonly string[]): void {
- const header = [
- `=== E2E Test: ${suiteName} ===`,
- `Started: ${new Date().toISOString()}`,
- `Node versions: ${nodeVersions.join(', ')}`,
- '',
- '',
- ].join('\n');
- writeFileSync(logPath, header, 'utf8');
+interface RunE2EInternalConfig extends E2EConfig {
+ cwd: string;
+ suiteName: string;
}
/**
- * Append a phase result to the DEBUG.log file.
+ * Creates Docker execution utilities for a specific Node version.
*/
-function appendPhaseToDebugLog(
- logPath: string,
+function createDockerExecutors(
+ config: RunE2EInternalConfig,
nodeVersion: string,
- phaseName: 'Setup' | 'Test',
- result: E2ETestResult
-): void {
- const lines = [
- `=== ${phaseName} (Node ${nodeVersion}) ===`,
- '',
- '[stdout]',
- result.stdout || '(empty)',
- '',
- '[stderr]',
- result.stderr || '(empty)',
- '',
- `[exit code] ${result.exitCode}`,
- '',
- '',
- ];
- appendFileSync(logPath, lines.join('\n'), 'utf8');
-}
-
-/**
- * Append a summary to the DEBUG.log file.
- */
-function appendSummaryToDebugLog(
- logPath: string,
- results: E2EPhaseResults[],
- allPassed: boolean
-): void {
- const lines = ['=== Summary ===', ''];
- for (const r of results) {
- const status = r.test.exitCode === 0 ? 'PASS' : 'FAIL';
- lines.push(`Node ${r.nodeVersion}: ${status}`);
- }
- lines.push('');
- lines.push(allPassed ? 'All tests passed!' : 'Some tests failed');
- lines.push('');
- lines.push(`Finished: ${new Date().toISOString()}`);
- lines.push('');
- appendFileSync(logPath, lines.join('\n'), 'utf8');
-}
-
-/**
- * Default summary printer for e2e test results.
- */
-function printDefaultSummary(
- suiteName: string,
- results: E2EPhaseResults[],
- allPassed: boolean
-): void {
- const divider = '='.repeat(Math.max(suiteName.length + 4, 30));
-
- console.log(`\n${divider}`);
- console.log(`Test Summary`);
- console.log(divider);
-
- for (const r of results) {
- const testStatus = r.test.exitCode === 0 ? 'PASS' : 'FAIL';
- console.log(`Node ${r.nodeVersion}: ${testStatus}`);
- }
-
- if (allPassed) {
- console.log(`\nAll tests passed!`);
- } else {
- console.error(`\nSome tests failed`);
- }
-}
-
-/**
- * Internal configuration for runE2E.
- */
-interface RunE2EInternalConfig extends E2EConfig {
- cwd: string;
- suiteName: string;
+ imageTag: string
+) {
+ const { cwd, suiteName, env } = config;
+ const containerEnv = buildContainerEnv(env);
+
+ const runCmd = async (command: string): Promise<E2ETestResult> => {
+ const containerName = `e2e-${suiteName}-${nodeVersion.replace(/\./g, '-')}-${Date.now()}`;
+ return runNodeContainer({
+ imageTag,
+ cmd: command,
+ cwd,
+ env: containerEnv,
+ name: containerName,
+ });
+ };
+
+ const runFixture = async (fixturePath: string): Promise<E2ETestResult> => {
+ return runCmd(`node ${fixturePath}`);
+ };
+
+ return { runCmd, runFixture };
}
/**
- * Runs e2e tests with Docker containers.
- *
- * For each Node version:
- * 1. Ensures Docker image exists (builds if needed)
- * 2. Runs setup command (if provided) and fixture in a single container
- * 3. Captures output and exit codes
- * 4. Calls assertion callbacks
- *
- * Writes detailed output to DEBUG.log and prints a summary.
+ * Runs e2e tests using bun:test.
+ * Creates a describe block per Node version and passes test utilities to defineTests.
*/
-export async function runE2E(config: RunE2EInternalConfig): Promise<never> {
- const { cwd, suiteName, fixture, setup, env, onSetup, onTest, printSummary } = config;
- const nodeVersions = resolveNodeVersions(config.nodeVersions);
+export function runE2E(config: RunE2EInternalConfig): void {
+ const { suiteName, defineTests } = config;
+ const nodeVersionMetaList = resolveNodeVersionMetaList(config.nodeVersions);
const repoRoot = getRepoRoot();
- const debugLogPath = resolve(repoRoot, cwd, 'DEBUG.log');
-
- // Initialize DEBUG.log
- initDebugLog(debugLogPath, suiteName, nodeVersions);
- console.log(`Debug log: ${debugLogPath}`);
-
- // Print header
- console.log(`\n${suiteName}`);
- console.log('='.repeat(suiteName.length));
- console.log(`Node versions: ${nodeVersions.join(', ')}`);
- console.log(`Fixture: ${fixture}\n`);
-
- // Check Docker availability
- let dockerOk = false;
- let dockerFailureMessage = '';
- try {
- const dockerCheck = await checkDocker({ repoRoot });
- dockerOk = dockerCheck.exitCode === 0;
- dockerFailureMessage = dockerCheck.stderr || dockerCheck.stdout || '';
- } catch (error) {
- dockerOk = false;
- dockerFailureMessage = error instanceof Error ? error.message : String(error);
- }
- if (!dockerOk) {
- const reason = dockerFailureMessage.trim() || 'Docker is not available';
- const message = `Skipping e2e suite because Docker is not available. Reason: ${reason}`;
- console.log(message);
- appendFileSync(debugLogPath, `\n${message}\n`, 'utf8');
- process.exit(0);
+ function renderNodeVersionMeta({ kind, value }: NodeVersionMeta) {
+ switch (kind) {
+ case 'current':
+ return `Node.js ${value} [current]`;
+ case 'overridden':
+ return `Node.js ${value} [overridden]`;
+ case 'static':
+ return `Node.js ${value}`;
+ }
}
- const results: E2EPhaseResults[] = [];
-
- try {
- for (const nodeVersion of nodeVersions) {
- console.log(`\n=== Running e2e test for Node.js ${nodeVersion} ===\n`);
-
- const imageTag = await ensureNodeImage(nodeVersion, { repoRoot });
+ for (const nodeVersionMeta of nodeVersionMetaList) {
+ describe(`${suiteName} (Node ${renderNodeVersionMeta(nodeVersionMeta)})`, () => {
+ let executors: ReturnType<typeof createDockerExecutors>;
- const phaseResult: E2EPhaseResults = {
- nodeVersion,
- test: undefined as unknown as E2ETestResult,
- };
+ // Ensure Docker image exists before tests run
+ beforeAll(async () => {
+ const imageTag = await ensureNodeImage(nodeVersionMeta.value, { repoRoot });
+ executors = createDockerExecutors(config, nodeVersionMeta.value, imageTag);
+ }, 600_000); // 10 minute timeout for Docker image build
- // Build combined command: setup (if provided) && fixture
- const fixtureCmd = `node ${fixture}`;
- const combinedCmd = setup ? `${setup} && ${fixtureCmd}` : fixtureCmd;
-
- if (setup) {
- console.log(`[Node ${nodeVersion}] Running setup: ${setup}`);
- }
- console.log(`[Node ${nodeVersion}] Running fixture: ${fixtureCmd}`);
-
- const containerName = `e2e-${suiteName}-${nodeVersion.replace(/\./g, '-')}`;
- const result = await runNodeContainer({
- imageTag,
- cmd: combinedCmd,
- cwd,
- env: buildContainerEnv(env),
- name: containerName,
+ // Call user's defineTests with bun:test functions and Docker utilities
+ defineTests({
+ runCmd: (cmd) => executors.runCmd(cmd),
+ runFixture: (path) => executors.runFixture(path),
});
-
- phaseResult.test = result;
-
- if (setup) {
- phaseResult.setup = result;
- console.log(`[Setup+Test stdout]\n${result.stdout || '(empty)'}`);
- console.log(`[Setup+Test stderr]\n${result.stderr || '(empty)'}`);
- console.log(`[Exit code] ${result.exitCode}\n`);
-
- appendPhaseToDebugLog(debugLogPath, nodeVersion, 'Setup', result);
- appendPhaseToDebugLog(debugLogPath, nodeVersion, 'Test', result);
-
- if (onSetup) {
- await onSetup(result);
- }
- } else {
- if (result.stdout) {
- console.log(`[Test stdout]\n${result.stdout}`);
- }
- if (result.stderr) {
- console.log(`[Test stderr]\n${result.stderr}`);
- }
- console.log(`[Test exit code] ${result.exitCode}\n`);
-
- appendPhaseToDebugLog(debugLogPath, nodeVersion, 'Test', result);
- }
-
- if (onTest) {
- await onTest(result);
- }
-
- results.push(phaseResult);
- }
-
- const allPassed = results.every((r) => r.test.exitCode === 0);
-
- appendSummaryToDebugLog(debugLogPath, results, allPassed);
-
- if (printSummary) {
- printSummary(results, allPassed);
- } else {
- printDefaultSummary(suiteName, results, allPassed);
- }
-
- process.exit(allPassed ? 0 : 1);
- } catch (error) {
- console.error('Test runner failed:', error);
- process.exit(1);
+ });
}
}
diff --git a/ts/e2e-tests/_utils/src/sanitize.ts b/ts/e2e-tests/_utils/src/sanitize.ts
new file mode 100644
index 000000000..0c7e6328f
--- /dev/null
+++ b/ts/e2e-tests/_utils/src/sanitize.ts
@@ -0,0 +1,26 @@
+/**
+ * Output sanitization utilities for stable test comparisons.
+ */
+
+/**
+ * Sanitize command output for stable snapshot comparisons.
+ * Removes ANSI escape codes, normalizes line endings, and trims whitespace.
+ *
+ * @param output - Raw command output (stdout or stderr)
+ * @returns Sanitized output suitable for assertions and snapshots
+ */
+export function sanitizeOutput(output: string): string {
+ return (
+ output
+ // Remove ANSI escape codes (colors, formatting)
+ .replace(/\x1b\[[0-9;]*m/g, '')
+ // Normalize line endings (Windows → Unix)
+ .replace(/\r\n/g, '\n')
+ // Trim trailing whitespace from each line
+ .split('\n')
+ .map((line) => line.trimEnd())
+ .join('\n')
+ // Trim leading/trailing whitespace from entire output
+ .trim()
+ );
+}
diff --git a/ts/e2e-tests/_utils/src/types.ts b/ts/e2e-tests/_utils/src/types.ts
index 7298b3c4e..2fd09ee8c 100644
--- a/ts/e2e-tests/_utils/src/types.ts
+++ b/ts/e2e-tests/_utils/src/types.ts
@@ -1,4 +1,11 @@
-export type NodeVersion = '20.18.0' | '20.19.0' | '22.12.0' | (string & {});
+import { WELL_KNOWN_NODE_VERSIONS } from './const';
+
+export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];
+
+export type NodeVersionMeta =
+ | { kind: 'static', value: Exclude<typeof WELL_KNOWN_NODE_VERSIONS[number], 'current'> }
+ | { kind: 'overridden', value: string }
+ | { kind: 'current', value: string };
/**
* Result of executing a command in a Docker container.
@@ -13,62 +20,51 @@ export interface E2ETestResult {
}
/**
- * Results for both phases of a two-phase e2e test.
+ * Context passed to defineTests callback.
*/
-export interface E2EPhaseResults {
- /** Node.js version this test ran against */
- nodeVersion: string;
- /** Result of the setup phase (undefined if no setup command) */
- setup?: E2ETestResult;
- /** Result of the test/fixture phase */
- test: E2ETestResult;
+export interface DefineTestsContext {
+ /** Run an arbitrary command in the Docker container */
+ runCmd: (command: string) => Promise<E2ETestResult>;
+ /** Run a fixture file with Node.js (equivalent to runCmd(`node ${path}`)) */
+ runFixture: (fixturePath: string) => Promise<E2ETestResult>;
}
-/**
- * Assertion callback for validating phase results.
- */
-export type E2EAssertionCallback = (result: E2ETestResult) => void | Promise<void>;
-
/**
* Configuration for e2e tests.
*/
export interface E2EConfig {
- /**
- * The fixture file to execute (e.g., 'fixtures/test.mjs').
- */
- fixture: string;
-
/**
* Node.js versions to test against.
+ * Each version creates a separate describe block.
* If not provided, defaults to the current Node runtime version.
*/
- nodeVersions?: readonly NodeVersion[];
+ nodeVersions?: readonly NodeVersionFromUser[];
/**
- * Setup command to run before the test fixture.
- * Runs inside the Docker container after dependencies are installed.
- */
- setup?: string;
-
- /**
- * Environment variables to pass to the container.
+ * Environment variables to pass to the Docker container.
*/
env?: Record<string, string | undefined>;
/**
- * Assertion callback for the setup phase.
- * Called after setup completes (if setup is defined).
- */
- onSetup?: E2EAssertionCallback;
-
- /**
- * Assertion callback for the test phase.
- * Called after the fixture completes.
- */
- onTest?: E2EAssertionCallback;
-
- /**
- * Custom summary printer. If not provided, uses default summary format.
+ * Define your tests using bun:test primitives.
+ * Called once per Node version during test registration.
+ *
+ * @example
+ * ```typescript
+ * defineTests: ({ describe, it, expect, beforeAll, runFixture }) => {
+ * let result: E2ETestResult;
+ *
+ * beforeAll(async () => {
+ * result = await runFixture('fixtures/test.mjs');
+ * }, 300_000);
+ *
+ * describe('output', () => {
+ * it('exits successfully', () => {
+ * expect(result.exitCode).toBe(0);
+ * });
+ * });
+ * }
+ * ```
*/
- printSummary?: (results: E2EPhaseResults[], allPassed: boolean) => void;
+ defineTests: (ctx: DefineTestsContext) => void;
}
diff --git a/ts/e2e-tests/runtimes/cloudflare/cf-workers-basic/package.json b/ts/e2e-tests/runtimes/cloudflare/cf-workers-basic/package.json
index e42828ef1..4359cb6ed 100644
--- a/ts/e2e-tests/runtimes/cloudflare/cf-workers-basic/package.json
+++ b/ts/e2e-tests/runtimes/cloudflare/cf-workers-basic/package.json
@@ -1,5 +1,5 @@
{
- "name": "@test-e2e/cf-workers-basic",
+ "name": "@e2e-tests/cf-workers-basic",
"version": "0.0.0",
"private": true,
"type": "module",
diff --git a/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/README.md b/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/README.md
index aaa1c150a..0eac3f9b0 100644
--- a/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/README.md
+++ b/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/README.md
@@ -29,7 +29,7 @@ Verifies that:
pnpm test:e2e
# Or from the monorepo root
-pnpm --filter @test-e2e/cf-workers-files test:e2e:cloudflare
+pnpm --filter @e2e-tests/cf-workers-files test:e2e:cloudflare
```
## Environment Variables
diff --git a/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/package.json b/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/package.json
index 7a4837dce..49bd6ce47 100644
--- a/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/package.json
+++ b/ts/e2e-tests/runtimes/cloudflare/cf-workers-files/package.json
@@ -1,5 +1,5 @@
{
- "name": "@test-e2e/cf-workers-files",
+ "name": "@e2e-tests/cf-workers-files",
"version": "0.0.0",
"private": true,
"type": "module",
diff --git a/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/package.json b/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/package.json
index e02a310e6..8da70c09e 100644
--- a/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/package.json
+++ b/ts/e2e-tests/runtimes/cloudflare/cf-workers-tool-router-ai/package.json
@@ -1,5 +1,5 @@
{
- "name": "@test-e2e/cf-workers-tool-router-ai",
+ "name": "@e2e-tests/cf-workers-tool-router-ai",
"version": "0.0.0",
"private": true,
"type": "module",
diff --git a/ts/e2e-tests/runtimes/node/cjs-basic/e2e.test.ts b/ts/e2e-tests/runtimes/node/cjs-basic/e2e.test.ts
new file mode 100644
index 000000000..8b884f5fd
--- /dev/null
+++ b/ts/e2e-tests/runtimes/node/cjs-basic/e2e.test.ts
@@ -0,0 +1,71 @@
+/**
+ * CommonJS compatibility e2e test
+ *
+ * Verifies that @composio/core can be imported using require() in Node.js.
+ */
+
+import { e2e, type E2ETestResult } from '@e2e-tests/utils';
+import { describe, it, expect, beforeAll } from 'bun:test';
+
+e2e(import.meta.url, {
+ nodeVersions: [
+ // may throw ERR_REQUIRE_ESM
+ '20.18.0',
+ // supports ESM by default
+ '20.19.0',
+ '22.12.0',
+ ],
+ defineTests: ({ runFixture }) => {
+ let result: E2ETestResult;
+
+ beforeAll(async () => {
+ result = await runFixture('fixtures/test.cjs');
+ });
+
+ describe('CommonJS compatibility', () => {
+ it('exits successfully', () => {
+ expect(result.exitCode).toBe(0);
+ });
+
+ it('require() succeeds', () => {
+ expect(result.stdout).toContain('Test 1 passed: require() succeeded');
+ });
+
+ it('exports Composio class', () => {
+ expect(result.stdout).toContain('Test 2 passed: Composio class is exported');
+ });
+
+ it('exports OpenAIProvider class', () => {
+ expect(result.stdout).toContain('Test 3 passed: OpenAIProvider class is exported');
+ });
+
+ it('instantiates OpenAIProvider successfully', () => {
+ expect(result.stdout).toContain('Test 4 passed: OpenAIProvider instantiated successfully');
+ });
+
+ it('exports AuthScheme', () => {
+ expect(result.stdout).toContain('Test 5 passed: AuthScheme is exported');
+ });
+
+ it('exports Error classes', () => {
+ expect(result.stdout).toContain('Test 6 passed: Error classes are exported');
+ });
+
+ it('exports jsonSchemaToZodSchema', () => {
+ expect(result.stdout).toContain('Test 7 passed: jsonSchemaToZodSchema is exported');
+ });
+
+ it('exports constants namespace', () => {
+ expect(result.stdout).toContain('Test 8 passed: constants namespace is exported');
+ });
+
+ it('exports logger', () => {
+ expect(result.stdout).toContain('Test 9 passed: logger is exported');
+ });
+
+ it('completes all tests', () => {
+ expect(result.stdout).toContain('All CommonJS compatibility tests passed!');
+ });
+ });
+ },
+});
diff --git a/ts/e2e-tests/runtimes/node/cjs-basic/e2e.ts b/ts/e2e-tests/runtimes/node/cjs-basic/e2e.ts
deleted file mode 100644
index d01f183fe..000000000
--- a/ts/e2e-tests/runtimes/node/cjs-basic/e2e.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * CommonJS compatibility e2e test
- *
- * Verifies that @composio/core can be imported using require() in Node.js.
- */
-
-import { e2e } from '@e2e-tests/utils';
-
-await e2e(import.meta.url, {
- nodeVersions: [
- // may throw ERR_REQUIRE_ESM
- '20.18.0',
- // supports ESM by default
- '20.19.0',
- '22.12.0',
- ],
- fixture: 'fixtures/test.cjs',
- onTest: (result) => {
- if (result.exitCode !== 0) {
- console.error('Test fixture failed');
- console.error('stderr:', result.stderr);
- throw new Error(`Test failed with exit code ${result.exitCode}`);
- }
-
- // Verify expected output from test.cjs
- const expectedOutputs = [
- 'Test 1 passed: require() succeeded',
- 'Test 2 passed: Composio class is exported',
- 'Test 3 passed: OpenAIProvider class is exported',
- 'Test 4 passed: OpenAIProvider instantiated successfully',
- 'Test 5 passed: AuthScheme is exported',
- 'Test 6 passed: Error classes are exported',
- 'Test 7 passed: jsonSchemaToZodSchema is exported',
- 'Test 8 passed: constants namespace is exported',
- 'Test 9 passed: logger is exported',
- 'All CommonJS compatibility tests passed!',
- ];
-
- for (const expected of expectedOutputs) {
- if (!result.stdout.includes(expected)) {
- throw new Error(`Expected output not found: "${expected}"`);
- }
- }
-
- console.log('Test fixture passed with expected output');
- },
-});
diff --git a/ts/e2e-tests/runtimes/node/cjs-basic/package.json b/ts/e2e-tests/runtimes/node/cjs-basic/package.json
index 29c75722d..bbfd3604c 100644
--- a/ts/e2e-tests/runtimes/node/cjs-basic/package.json
+++ b/ts/e2e-tests/runtimes/node/cjs-basic/package.json
@@ -1,11 +1,12 @@
{
- "name": "@test-e2e/node-cjs-basic",
+ "name": "@e2e-tests/node-cjs-basic",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
- "test:e2e": "bun e2e.ts",
- "test:e2e:node": "bun e2e.ts"
+ "typecheck": "tsc --noEmit",
+ "test:e2e": "bun test e2e.test.ts",
+ "test:e2e:node": "bun test e2e.test.ts"
},
"devDependencies": {
"@composio/core": "workspace:*",
diff --git a/ts/e2e-tests/runtimes/node/cjs-basic/tsconfig.json b/ts/e2e-tests/runtimes/node/cjs-basic/tsconfig.json
index cd39ecb35..3eeaa418d 100644
--- a/ts/e2e-tests/runtimes/node/cjs-basic/tsconfig.json
+++ b/ts/e2e-tests/runtimes/node/cjs-basic/tsconfig.json
@@ -8,5 +8,5 @@
"skipLibCheck": true,
"noEmit": true
},
- "include": ["e2e.ts"]
+ "include": ["e2e.test.ts"]
}
diff --git a/ts/e2e-tests/runtimes/node/esm-basic/e2e.test.ts b/ts/e2e-tests/runtimes/node/esm-basic/e2e.test.ts
new file mode 100644
index 000000000..2ff66e56f
--- /dev/null
+++ b/ts/e2e-tests/runtimes/node/esm-basic/e2e.test.ts
@@ -0,0 +1,75 @@
+/**
+ * ESM compatibility e2e test
+ *
+ * Verifies that @composio/core can be imported using ESM import syntax in Node.js.
+ */
+
+import { e2e, type E2ETestResult } from '@e2e-tests/utils';
+import { describe, it, expect, beforeAll } from 'bun:test';
+
+e2e(import.meta.url, {
+ nodeVersions: [
+ // may throw ERR_REQUIRE_ESM
+ '20.18.0',
+ // supports ESM by default
+ '20.19.0',
+ '22.12.0',
+ ],
+ defineTests: ({ runFixture }) => {
+ let result: E2ETestResult;
+
+ beforeAll(async () => {
+ result = await runFixture('fixtures/test.mjs');
+ });
+
+ describe('ESM compatibility', () => {
+ it('exits successfully', () => {
+ expect(result.exitCode).toBe(0);
+ });
+
+ it('import() succeeds', () => {
+ expect(result.stdout).toContain('Test 1 passed: import() succeeded');
+ });
+
+ it('exports Composio class', () => {
+ expect(result.stdout).toContain('Test 2 passed: Composio class is exported');
+ });
+
+ it('exports OpenAIProvider class', () => {
+ expect(result.stdout).toContain('Test 3 passed: OpenAIProvider class is exported');
+ });
+
+ it('instantiates OpenAIProvider successfully', () => {
+ expect(result.stdout).toContain('Test 4 passed: OpenAIProvider instantiated successfully');
+ });
+
+ it('exports AuthScheme', () => {
+ expect(result.stdout).toContain('Test 5 passed: AuthScheme is exported');
+ });
+
+ it('exports Error classes', () => {
+ expect(result.stdout).toContain('Test 6 passed: Error classes are exported');
+ });
+
+ it('exports jsonSchemaToZodSchema', () => {
+ expect(result.stdout).toContain('Test 7 passed: jsonSchemaToZodSchema is exported');
+ });
+
+ it('exports constants namespace', () => {
+ expect(result.stdout).toContain('Test 8 passed: constants namespace is exported');
+ });
+
+ it('exports logger', () => {
+ expect(result.stdout).toContain('Test 9 passed: logger is exported');
+ });
+
+ it('supports static import syntax', () => {
+ expect(result.stdout).toContain('Test 10 passed: Static import syntax works');
+ });
+
+ it('completes all tests', () => {
+ expect(result.stdout).toContain('All ESM compatibility tests passed!');
+ });
+ });
+ },
+});
diff --git a/ts/e2e-tests/runtimes/node/esm-basic/e2e.ts b/ts/e2e-tests/runtimes/node/esm-basic/e2e.ts
deleted file mode 100644
index 78f38d85a..000000000
--- a/ts/e2e-tests/runtimes/node/esm-basic/e2e.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * ESM compatibility e2e test
- *
- * Verifies that @composio/core can be imported using ESM import syntax in Node.js.
- */
-
-import { e2e } from '@e2e-tests/utils';
-
-await e2e(import.meta.url, {
- nodeVersions: [
- // may throw ERR_REQUIRE_ESM
- '20.18.0',
- // supports ESM by default
- '20.19.0',
- '22.12.0',
- ],
- fixture: 'fixtures/test.mjs',
- onTest: (result) => {
- if (result.exitCode !== 0) {
- console.error('Test fixture failed');
- console.error('stderr:', result.stderr);
- throw new Error(`Test failed with exit code ${result.exitCode}`);
- }
-
- // Verify expected output from test.mjs
- const expectedOutputs = [
- 'Test 1 passed: import() succeeded',
- 'Test 2 passed: Composio class is exported',
- 'Test 3 passed: OpenAIProvider class is exported',
- 'Test 4 passed: OpenAIProvider instantiated successfully',
- 'Test 5 passed: AuthScheme is exported',
- 'Test 6 passed: Error classes are exported',
- 'Test 7 passed: jsonSchemaToZodSchema is exported',
- 'Test 8 passed: constants namespace is exported',
- 'Test 9 passed: logger is exported',
- 'Test 10 passed: Static import syntax works',
- 'All ESM compatibility tests passed!',
- ];
-
- for (const expected of expectedOutputs) {
- if (!result.stdout.includes(expected)) {
- throw new Error(`Expected output not found: "${expected}"`);
- }
- }
-
- console.log('Test fixture passed with expected output');
- },
-});
diff --git a/ts/e2e-tests/runtimes/node/esm-basic/package.json b/ts/e2e-tests/runtimes/node/esm-basic/package.json
index 88ee634b2..75d53a4c5 100644
--- a/ts/e2e-tests/runtimes/node/esm-basic/package.json
+++ b/ts/e2e-tests/runtimes/node/esm-basic/package.json
@@ -1,11 +1,12 @@
{
- "name": "@test-e2e/node-esm-basic",
+ "name": "@e2e-tests/node-esm-basic",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
- "test:e2e": "bun e2e.ts",
- "test:e2e:node": "bun e2e.ts"
+ "typecheck": "tsc --noEmit",
+ "test:e2e": "bun test e2e.test.ts",
+ "test:e2e:node": "bun test e2e.test.ts"
},
"devDependencies": {
"@composio/core": "workspace:*",
diff --git a/ts/e2e-tests/runtimes/node/esm-basic/tsconfig.json b/ts/e2e-tests/runtimes/node/esm-basic/tsconfig.json
index cd39ecb35..3eeaa418d 100644
--- a/ts/e2e-tests/runtimes/node/esm-basic/tsconfig.json
+++ b/ts/e2e-tests/runtimes/node/esm-basic/tsconfig.json
@@ -8,5 +8,5 @@
"skipLibCheck": true,
"noEmit": true
},
- "include": ["e2e.ts"]
+ "include": ["e2e.test.ts"]
}
diff --git a/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.test.ts b/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.test.ts
new file mode 100644
index 000000000..41e1bd05d
--- /dev/null
+++ b/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.test.ts
@@ -0,0 +1,65 @@
+/**
+ * OpenAI v6 + Zod v4 compatibility e2e test
+ *
+ * Verifies that @composio/core works correctly with openai@6 and zod@4,
+ * specifically testing the fix for https://github.com/ComposioHQ/composio/issues/2336
+ */
+
+import { e2e, type E2ETestResult } from '@e2e-tests/utils';
+import { describe, it, expect, beforeAll } from 'bun:test';
+
+declare module 'bun' {
+ interface Env {
+ COMPOSIO_API_KEY: string;
+ }
+}
+
+e2e(import.meta.url, {
+ nodeVersions: ['20.19.0', '22.12.0'],
+ env: {
+ COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
+ },
+ defineTests: ({ runCmd, runFixture }) => {
+ let setupResult: E2ETestResult;
+ let testResult: E2ETestResult;
+
+ beforeAll(async () => {
+ // Run npm install first
+ setupResult = await runCmd('npm --prefix fixtures install --legacy-peer-deps');
+ // Then run the test fixture
+ testResult = await runFixture('fixtures/index.mjs');
+ });
+
+ describe('setup', () => {
+ it('npm install completes successfully', () => {
+ expect(setupResult.exitCode).toBe(0);
+ });
+ });
+
+ describe('OpenAI v6 + Zod v4 compatibility', () => {
+ it('exits successfully', () => {
+ expect(testResult.exitCode).toBe(0);
+ });
+
+ it('zod@4 works', () => {
+ expect(testResult.stdout).toContain('zod@4 works');
+ });
+
+ it('openai@5 works', () => {
+ expect(testResult.stdout).toContain('openai@5 works');
+ });
+
+ it('@composio/core works', () => {
+ expect(testResult.stdout).toContain('@composio/core works');
+ });
+
+ it('wrapTool works', () => {
+ expect(testResult.stdout).toContain('wrapTool works');
+ });
+
+ it('all packages work together', () => {
+ expect(testResult.stdout).toContain('All packages work together!');
+ });
+ });
+ },
+});
diff --git a/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.ts b/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.ts
deleted file mode 100644
index dee181df4..000000000
--- a/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * OpenAI v6 + Zod v4 compatibility e2e test
- *
- * Verifies that @composio/core works correctly with openai@6 and zod@4,
- * specifically testing the fix for https://github.com/ComposioHQ/composio/issues/2336
- */
-
-import { e2e } from '@e2e-tests/utils';
-
-declare module "bun" {
- interface Env {
- COMPOSIO_API_KEY: string;
- }
-}
-
-await e2e(import.meta.url, {
- nodeVersions: ['20.19.0', '22.12.0'],
- setup: 'npm --prefix fixtures install --legacy-peer-deps',
- fixture: 'fixtures/index.mjs',
- env: {
- COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
- },
- onSetup: (result) => {
- if (result.exitCode !== 0) {
- console.error('npm install failed');
- console.error('stderr:', result.stderr);
- throw new Error(`Setup failed with exit code ${result.exitCode}`);
- }
- console.log('npm install completed successfully');
- },
- onTest: (result) => {
- if (result.exitCode !== 0) {
- console.error('Test fixture failed');
- console.error('stderr:', result.stderr);
- throw new Error(`Test failed with exit code ${result.exitCode}`);
- }
-
- // Verify expected output from fixtures/index.mjs
- const expectedOutputs = [
- 'zod@4 works',
- 'openai@5 works',
- '@composio/core works',
- 'wrapTool works',
- 'All packages work together!',
- ];
-
- for (const expected of expectedOutputs) {
- if (!result.stdout.includes(expected)) {
- throw new Error(`Expected output not found: "${expected}"`);
- }
- }
-
- console.log('Test fixture passed with expected output');
- },
-});
diff --git a/ts/e2e-tests/runtimes/node/openai-zod4-compat/package.json b/ts/e2e-tests/runtimes/node/openai-zod4-compat/package.json
index a13db25f1..eb6973e93 100644
--- a/ts/e2e-tests/runtimes/node/openai-zod4-compat/package.json
+++ b/ts/e2e-tests/runtimes/node/openai-zod4-compat/package.json
@@ -1,11 +1,12 @@
{
- "name": "@test-e2e/node-openai-zod4-compat",
+ "name": "@e2e-tests/node-openai-zod4-compat",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
- "test:e2e": "bun e2e.ts",
- "test:e2e:node": "bun e2e.ts"
+ "typecheck": "tsc --noEmit",
+ "test:e2e": "bun test e2e.test.ts",
+ "test:e2e:node": "bun test e2e.test.ts"
},
"devDependencies": {
"@e2e-tests/utils": "workspace:*"
diff --git a/ts/e2e-tests/runtimes/node/openai-zod4-compat/tsconfig.json b/ts/e2e-tests/runtimes/node/openai-zod4-compat/tsconfig.json
index cd39ecb35..3eeaa418d 100644
--- a/ts/e2e-tests/runtimes/node/openai-zod4-compat/tsconfig.json
+++ b/ts/e2e-tests/runtimes/node/openai-zod4-compat/tsconfig.json
@@ -8,5 +8,5 @@
"skipLibCheck": true,
"noEmit": true
},
- "include": ["e2e.ts"]
+ "include": ["e2e.test.ts"]
}
diff --git a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.test.ts b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.test.ts
new file mode 100644
index 000000000..26d351fd7
--- /dev/null
+++ b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.test.ts
@@ -0,0 +1,53 @@
+/**
+ * TypeScript .mjs import resolution e2e test
+ *
+ * Verifies that generated TypeScript files with .mjs imports
+ * can be compiled successfully with moduleResolution: "nodenext".
+ *
+ * Requires COMPOSIO_API_KEY environment variable to be set.
+ */
+
+import { e2e, type E2ETestResult } from '@e2e-tests/utils';
+import { describe, it, expect, beforeAll } from 'bun:test';
+
+declare module 'bun' {
+ interface Env {
+ COMPOSIO_API_KEY: string;
+ }
+}
+
+e2e(import.meta.url, {
+ nodeVersions: ['current'],
+ env: {
+ COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
+ },
+ defineTests: ({ runFixture }) => {
+ let result: E2ETestResult;
+
+ beforeAll(async () => {
+ result = await runFixture('fixtures/index.mjs');
+ }, 300_000);
+
+ describe('TypeScript .mjs import resolution', () => {
+ it('exits successfully', () => {
+ expect(result.exitCode).toBe(0);
+ });
+
+ it('composio ts generate succeeds', () => {
+ expect(result.stdout).toContain('Test 1 passed: composio ts generate succeeded');
+ });
+
+ it('generated files exist', () => {
+ expect(result.stdout).toContain('Test 2 passed: Generated files exist');
+ });
+
+ it('TypeScript compilation succeeds', () => {
+ expect(result.stdout).toContain('Test 3 passed: TypeScript compilation succeeded');
+ });
+
+ it('completes all tests', () => {
+ expect(result.stdout).toContain('All tests passed!');
+ });
+ });
+ },
+});
diff --git a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.ts b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.ts
deleted file mode 100644
index 626a5c307..000000000
--- a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/e2e.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * TypeScript .mjs import resolution e2e test
- *
- * Verifies that generated TypeScript files with .mjs imports
- * can be compiled successfully with moduleResolution: "nodenext".
- *
- * Requires COMPOSIO_API_KEY environment variable to be set.
- */
-
-import { e2e } from '@e2e-tests/utils';
-
-declare module "bun" {
- interface Env {
- COMPOSIO_API_KEY: string;
- }
-}
-
-await e2e(import.meta.url, {
- nodeVersions: ['20.19.0', '22.12.0'],
- fixture: 'test.mjs',
- env: {
- COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
- },
- onTest: (result) => {
- if (result.exitCode !== 0) {
- console.error('Test fixture failed');
- console.error('stderr:', result.stderr);
- throw new Error(`Test failed with exit code ${result.exitCode}`);
- }
-
- // Verify expected output from test.mjs
- const expectedOutputs = [
- 'Test 1 passed: composio ts generate succeeded',
- 'Test 2 passed: Generated files exist',
- 'Test 3 passed: TypeScript compilation succeeded',
- 'All tests passed!',
- ];
-
- for (const expected of expectedOutputs) {
- if (!result.stdout.includes(expected)) {
- throw new Error(`Expected output not found: "${expected}"`);
- }
- }
-
- console.log('Test fixture passed with expected output');
- },
-});
diff --git a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/test.mjs b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/fixtures/index.mjs
similarity index 100%
rename from ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/test.mjs
rename to ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/fixtures/index.mjs
diff --git a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/fixtures/tsconfig.json b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/fixtures/tsconfig.json
new file mode 100644
index 000000000..cad8f30d5
--- /dev/null
+++ b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/fixtures/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "compilerOptions": {
+ "target": "es2022",
+ "module": "nodenext",
+ "moduleResolution": "nodenext",
+ "strict": true,
+ "skipLibCheck": true,
+ "noEmit": true
+ },
+ "include": [
+ "generated"
+ ]
+}
diff --git a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/package.json b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/package.json
index b545209d2..88383a75d 100644
--- a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/package.json
+++ b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/package.json
@@ -1,11 +1,12 @@
{
- "name": "@test-e2e/node-typescript-mjs-import-nodenext",
+ "name": "@e2e-tests/node-typescript-mjs-import-nodenext",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
- "test:e2e": "bun e2e.ts",
- "test:e2e:node": "bun e2e.ts"
+ "typecheck": "tsc --noEmit",
+ "test:e2e": "bun test e2e.test.ts",
+ "test:e2e:node": "bun test e2e.test.ts"
},
"devDependencies": {
"@composio/cli": "workspace:*",
diff --git a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/tsconfig.json b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/tsconfig.json
index 7758999f1..265f00ede 100644
--- a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/tsconfig.json
+++ b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/tsconfig.json
@@ -1,14 +1,14 @@
{
+ "$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "es2022",
- "module": "nodenext",
- "moduleResolution": "nodenext",
- "declaration": true,
- "outDir": "./dist",
- "rootDir": "./generated",
+ "module": "esnext",
+ "moduleResolution": "bundler",
"strict": true,
- "esModuleInterop": true,
- "skipLibCheck": true
+ "skipLibCheck": true,
+ "noEmit": true
},
- "include": ["generated"]
-}
+ "include": [
+ "e2e.test.ts"
+ ]
+}
\ No newline at end of file