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.

chore(ts/e2e): fix @e2e-tests/node-openai-zod4-compat

jkomyno94d81c21ae0f
diff --git a/ts/e2e-tests/README.md b/ts/e2e-tests/README.md
index ef082bed5..3f2bfedbf 100644
--- a/ts/e2e-tests/README.md
+++ b/ts/e2e-tests/README.md
@@ -8,11 +8,17 @@ End-to-end tests for `@composio/core` across different JavaScript runtimes.
ts/e2e-tests/
├── _utils/ # Shared test infrastructure
│ ├── Dockerfile.node # Docker image for Node.js tests
+│ ├── scripts/ # Docker build and cleanup scripts
+│ │ ├── docker-build.ts # Pre-build images for all Node versions
+│ │ └── docker-clean.ts # Remove all e2e Docker images
│ ├── src/ # TypeScript runner utilities
+│ │ ├── config.ts # Configuration utilities
+│ │ ├── const.ts # Well-known Node.js versions
│ │ ├── e2e.ts # Main e2e test entry point
-│ │ ├── runner.ts # Docker test runner
│ │ ├── image-lifecycle.ts # Docker image build/run utilities
-│ │ ├── config.ts # Configuration utilities
+│ │ ├── index.ts # Public exports
+│ │ ├── runner.ts # Docker test runner
+│ │ ├── sanitize.ts # Output sanitization utilities
│ │ └── types.ts # TypeScript type definitions
│ └── README.md # Utils documentation
└── runtimes/
@@ -41,7 +47,7 @@ pnpm test:e2e
pnpm test:e2e:node
```
-Runs Node.js tests in Docker with the default Node.js version (20.19.0).
+Runs Node.js tests in Docker using `bun test`. The default Node.js version is determined by the current runtime.
To run with a specific Node.js version:
@@ -62,21 +68,31 @@ pnpm test:e2e:cloudflare
1. Create a new directory under `runtimes/node/` (e.g., `runtimes/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:
+4. Create an `e2e.test.ts` file with inline configuration:
```typescript
-import { e2e } from '@e2e-tests/utils';
+import { e2e, type E2ETestResult } from '@e2e-tests/utils';
+import { describe, it, expect, beforeAll } from 'bun:test';
-await e2e(import.meta.url, {
- fixture: 'fixtures/test.mjs',
+e2e(import.meta.url, {
nodeVersions: ['20.18.0', '22.12.0'], // Optional: defaults to current runtime
- setup: 'npm install', // Optional: setup command
env: { MY_VAR: process.env.MY_VAR }, // Optional: env vars
- onTest: (result) => {
- if (result.exitCode !== 0) {
- throw new Error(`Test failed with exit code ${result.exitCode}`);
- }
- // Add assertions for expected output
+ defineTests: ({ runFixture }) => {
+ let result: E2ETestResult;
+
+ beforeAll(async () => {
+ result = await runFixture('fixtures/test.mjs');
+ });
+
+ describe('output', () => {
+ it('exits successfully', () => {
+ expect(result.exitCode).toBe(0);
+ });
+
+ it('contains expected output', () => {
+ expect(result.stdout).toContain('expected text');
+ });
+ });
},
});
```
diff --git a/ts/e2e-tests/_utils/README.md b/ts/e2e-tests/_utils/README.md
index a573a47a5..177218c71 100644
--- a/ts/e2e-tests/_utils/README.md
+++ b/ts/e2e-tests/_utils/README.md
@@ -7,32 +7,70 @@ Shared infrastructure for running `@composio/core` end-to-end tests in isolated
| File/Directory | Purpose |
| ----------------- | ---------------------------------------------------- |
| `src/` | TypeScript utilities (e2e runner, config, types) |
+| `scripts/` | Docker build and cleanup scripts |
| `Dockerfile.node` | Multi-stage Dockerfile for Node.js test environments |
## API
### `e2e`
-The main entry point for e2e tests. Automatically infers the working directory and suite name from the caller's location:
+The main entry point for e2e tests. Automatically infers the working directory and suite name from the caller's location. Uses `bun:test` for the test framework.
```typescript
-import { e2e } from '@e2e-tests/utils';
+import { e2e, type E2ETestResult } from '@e2e-tests/utils';
+import { describe, it, expect, beforeAll } from 'bun:test';
-await e2e(import.meta.url, {
+e2e(import.meta.url, {
nodeVersions: ['20.18.0', '20.19.0', '22.12.0'], // optional
- setup: 'npm install', // optional setup command
- fixture: 'fixtures/test.mjs', // required fixture file
- env: { MY_VAR: 'value' }, // optional env vars
- onSetup: (result) => { /* validate setup */ }, // optional
- onTest: (result) => { // optional
- if (result.exitCode !== 0) {
- throw new Error(`Test failed with exit code ${result.exitCode}`);
- }
+ env: { MY_VAR: 'value' }, // optional env vars
+ defineTests: ({ runCmd, runFixture }) => {
+ let result: E2ETestResult;
+
+ beforeAll(async () => {
+ result = await runFixture('fixtures/test.mjs');
+ });
+
+ describe('output', () => {
+ it('exits successfully', () => {
+ expect(result.exitCode).toBe(0);
+ });
+ });
},
});
```
-### Node Version Resolution
+### `DefineTestsContext`
+
+The context passed to the `defineTests` callback:
+
+| Function | Description |
+| -------------------------------- | ----------------------------------------------------------- |
+| `runCmd(command: string)` | Run arbitrary command in Docker container |
+| `runFixture(fixturePath: string)` | Run a fixture file with Node.js (equivalent to `runCmd(\`node ${path}\`)`) |
+
+### `E2ETestResult`
+
+Result returned by `runCmd` and `runFixture`:
+
+```typescript
+interface E2ETestResult {
+ exitCode: number; // Exit code from the command (0 = success)
+ stdout: string; // Captured stdout
+ stderr: string; // Captured stderr
+}
+```
+
+### `sanitizeOutput`
+
+Utility for stable test comparisons. Removes ANSI escape codes, normalizes line endings, and trims whitespace.
+
+```typescript
+import { sanitizeOutput } from '@e2e-tests/utils';
+
+const clean = sanitizeOutput(result.stdout);
+```
+
+## Node Version Resolution
Node.js versions to test are resolved in this order:
@@ -40,14 +78,24 @@ Node.js versions to test are resolved in this order:
2. **`config.nodeVersions`**: Use the provided array
3. **Default**: Use `[process.versions.node]` (current runtime)
-### DEBUG.log
+### Well-Known Node Versions
-Each test run generates a `DEBUG.log` file in the test directory containing:
-- Test start timestamp
-- Node.js versions tested
-- stdout/stderr for each phase (setup and test)
-- Exit codes
-- Summary with pass/fail status
+The following versions are pre-defined in `const.ts`:
+
+- `20.18.0`
+- `20.19.0`
+- `22.12.0`
+- `current` (resolves to current Node runtime version)
+
+## Scripts
+
+```bash
+# Pre-build Docker images for all well-known Node versions
+pnpm docker:build
+
+# Remove all e2e Docker images
+pnpm docker:clean
+```
## Behavior
diff --git a/ts/e2e-tests/runtimes/node/cjs-basic/README.md b/ts/e2e-tests/runtimes/node/cjs-basic/README.md
index 6c73b418f..40369f6a5 100644
--- a/ts/e2e-tests/runtimes/node/cjs-basic/README.md
+++ b/ts/e2e-tests/runtimes/node/cjs-basic/README.md
@@ -35,5 +35,3 @@ This ensures tests run against exact Node.js versions independent of the develop
```bash
pnpm test:e2e
```
-
-Debug output is written to `DEBUG.log`.
diff --git a/ts/e2e-tests/runtimes/node/esm-basic/README.md b/ts/e2e-tests/runtimes/node/esm-basic/README.md
index b68079b08..719507192 100644
--- a/ts/e2e-tests/runtimes/node/esm-basic/README.md
+++ b/ts/e2e-tests/runtimes/node/esm-basic/README.md
@@ -36,5 +36,3 @@ This ensures tests run against exact Node.js versions independent of the develop
```bash
pnpm test:e2e
```
-
-Debug output is written to `DEBUG.log`.
diff --git a/ts/e2e-tests/runtimes/node/openai-zod4-compat/README.md b/ts/e2e-tests/runtimes/node/openai-zod4-compat/README.md
index dcf39c101..61a40b884 100644
--- a/ts/e2e-tests/runtimes/node/openai-zod4-compat/README.md
+++ b/ts/e2e-tests/runtimes/node/openai-zod4-compat/README.md
@@ -25,5 +25,3 @@ This ensures tests run against exact Node.js versions independent of the develop
```bash
pnpm test:e2e
```
-
-Debug output is written to `DEBUG.log`.
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
index 41e1bd05d..1b5f52990 100644
--- a/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.test.ts
+++ b/ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.test.ts
@@ -19,47 +19,45 @@ e2e(import.meta.url, {
env: {
COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
},
- defineTests: ({ runCmd, runFixture }) => {
- let setupResult: E2ETestResult;
- let testResult: E2ETestResult;
+ defineTests: ({ runCmd }) => {
+ let result: 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');
+ result = await runCmd(
+ 'npm --prefix fixtures install --legacy-peer-deps && node fixtures/index.mjs'
+ );
});
describe('setup', () => {
it('npm install completes successfully', () => {
- expect(setupResult.exitCode).toBe(0);
+ expect(result.stdout).toMatch(/added \d+ packages/);
});
});
describe('OpenAI v6 + Zod v4 compatibility', () => {
it('exits successfully', () => {
- expect(testResult.exitCode).toBe(0);
+ expect(result.exitCode).toBe(0);
});
it('zod@4 works', () => {
- expect(testResult.stdout).toContain('zod@4 works');
+ expect(result.stdout).toContain('zod@4 works');
});
it('openai@5 works', () => {
- expect(testResult.stdout).toContain('openai@5 works');
+ expect(result.stdout).toContain('openai@5 works');
});
it('@composio/core works', () => {
- expect(testResult.stdout).toContain('@composio/core works');
+ expect(result.stdout).toContain('@composio/core works');
});
it('wrapTool works', () => {
- expect(testResult.stdout).toContain('wrapTool works');
+ expect(result.stdout).toContain('wrapTool works');
});
it('all packages work together', () => {
- expect(testResult.stdout).toContain('All packages work together!');
+ expect(result.stdout).toContain('All packages work together!');
});
- });
+ },);
},
});
diff --git a/ts/e2e-tests/runtimes/node/openai-zod4-compat/fixtures/package.json b/ts/e2e-tests/runtimes/node/openai-zod4-compat/fixtures/package.json
index c31920d35..17c797253 100644
--- a/ts/e2e-tests/runtimes/node/openai-zod4-compat/fixtures/package.json
+++ b/ts/e2e-tests/runtimes/node/openai-zod4-compat/fixtures/package.json
@@ -2,7 +2,7 @@
"private": true,
"type": "module",
"dependencies": {
- "@composio/core": "workspace:*",
+ "@composio/core": "file:/app/ts/packages/core",
"openai": "^6.16.0",
"zod": "^4.3.5"
}
diff --git a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/README.md b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/README.md
index fc0a93d59..1115298f8 100644
--- a/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/README.md
+++ b/ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/README.md
@@ -24,9 +24,9 @@ This causes `TS2307: Cannot find module './foo.mjs'` errors.
## Isolation Tool
-**Docker** with Node.js versions: 20.19.0, 22.12.0
+**Docker** with Node.js version: current runtime
-This ensures tests run against exact Node.js versions independent of the developer's local setup.
+This test uses the current Node.js runtime version for simplicity.
## Running
@@ -34,8 +34,6 @@ This ensures tests run against exact Node.js versions independent of the develop
pnpm test:e2e
```
-Debug output is written to `DEBUG.log`.
-
## Expected Behavior
- **If bug exists (importExtension: 'mjs')**: TypeScript compilation fails with TS2307