@devries-cameron20 / composio Mirror · read-only / commits / 94d81c21a
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

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

jkomyno committed Jan 27, 2026 at 00:58 UTC 94d81c21ae0f9fb3ab24b5d7fc473feca26c5861
8 files changed +112 -58
ts/e2e-tests/README.md
+29 -13
@@ -8,11 +8,17 @@ End-to-end tests for `@composio/core` across different JavaScript runtimes.
8 ts/e2e-tests/
9 ├── _utils/ # Shared test infrastructure
10 │ ├── Dockerfile.node # Docker image for Node.js tests
11 +│ ├── scripts/ # Docker build and cleanup scripts
12 +│ │ ├── docker-build.ts # Pre-build images for all Node versions
13 +│ │ └── docker-clean.ts # Remove all e2e Docker images
14 │ ├── src/ # TypeScript runner utilities
15 +│ │ ├── config.ts # Configuration utilities
16 +│ │ ├── const.ts # Well-known Node.js versions
17 │ │ ├── e2e.ts # Main e2e test entry point
13 -│ │ ├── runner.ts # Docker test runner
18 │ │ ├── image-lifecycle.ts # Docker image build/run utilities
15 -│ │ ├── config.ts # Configuration utilities
19 +│ │ ├── index.ts # Public exports
20 +│ │ ├── runner.ts # Docker test runner
21 +│ │ ├── sanitize.ts # Output sanitization utilities
22 │ │ └── types.ts # TypeScript type definitions
23 │ └── README.md # Utils documentation
24 └── runtimes/
@@ -41,7 +47,7 @@ pnpm test:e2e
47 pnpm test:e2e:node
48 ```
49
44 -Runs Node.js tests in Docker with the default Node.js version (20.19.0).
50 +Runs Node.js tests in Docker using `bun test`. The default Node.js version is determined by the current runtime.
51
52 To run with a specific Node.js version:
53
@@ -62,21 +68,31 @@ pnpm test:e2e:cloudflare
68 1. Create a new directory under `runtimes/node/` (e.g., `runtimes/node/my-test`)
69 2. Add a `package.json` with name `@e2e-tests/node-my-test`
70 3. Add `test:e2e` and `test:e2e:node` scripts
65 -4. Create an `e2e.ts` file with inline configuration:
71 +4. Create an `e2e.test.ts` file with inline configuration:
72
73 ```typescript
68 -import { e2e } from '@e2e-tests/utils';
74 +import { e2e, type E2ETestResult } from '@e2e-tests/utils';
75 +import { describe, it, expect, beforeAll } from 'bun:test';
76
70 -await e2e(import.meta.url, {
71 - fixture: 'fixtures/test.mjs',
77 +e2e(import.meta.url, {
78 nodeVersions: ['20.18.0', '22.12.0'], // Optional: defaults to current runtime
73 - setup: 'npm install', // Optional: setup command
79 env: { MY_VAR: process.env.MY_VAR }, // Optional: env vars
75 - onTest: (result) => {
76 - if (result.exitCode !== 0) {
77 - throw new Error(`Test failed with exit code ${result.exitCode}`);
78 - }
79 - // Add assertions for expected output
80 + defineTests: ({ runFixture }) => {
81 + let result: E2ETestResult;
82 +
83 + beforeAll(async () => {
84 + result = await runFixture('fixtures/test.mjs');
85 + });
86 +
87 + describe('output', () => {
88 + it('exits successfully', () => {
89 + expect(result.exitCode).toBe(0);
90 + });
91 +
92 + it('contains expected output', () => {
93 + expect(result.stdout).toContain('expected text');
94 + });
95 + });
96 },
97 });
98 ```
ts/e2e-tests/_utils/README.md
+67 -19
@@ -7,32 +7,70 @@ Shared infrastructure for running `@composio/core` end-to-end tests in isolated
7 | File/Directory | Purpose |
8 | ----------------- | ---------------------------------------------------- |
9 | `src/` | TypeScript utilities (e2e runner, config, types) |
10 +| `scripts/` | Docker build and cleanup scripts |
11 | `Dockerfile.node` | Multi-stage Dockerfile for Node.js test environments |
12
13 ## API
14
15 ### `e2e`
16
16 -The main entry point for e2e tests. Automatically infers the working directory and suite name from the caller's location:
17 +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.
18
19 ```typescript
19 -import { e2e } from '@e2e-tests/utils';
20 +import { e2e, type E2ETestResult } from '@e2e-tests/utils';
21 +import { describe, it, expect, beforeAll } from 'bun:test';
22
21 -await e2e(import.meta.url, {
23 +e2e(import.meta.url, {
24 nodeVersions: ['20.18.0', '20.19.0', '22.12.0'], // optional
23 - setup: 'npm install', // optional setup command
24 - fixture: 'fixtures/test.mjs', // required fixture file
25 - env: { MY_VAR: 'value' }, // optional env vars
26 - onSetup: (result) => { /* validate setup */ }, // optional
27 - onTest: (result) => { // optional
28 - if (result.exitCode !== 0) {
29 - throw new Error(`Test failed with exit code ${result.exitCode}`);
30 - }
25 + env: { MY_VAR: 'value' }, // optional env vars
26 + defineTests: ({ runCmd, runFixture }) => {
27 + let result: E2ETestResult;
28 +
29 + beforeAll(async () => {
30 + result = await runFixture('fixtures/test.mjs');
31 + });
32 +
33 + describe('output', () => {
34 + it('exits successfully', () => {
35 + expect(result.exitCode).toBe(0);
36 + });
37 + });
38 },
39 });
40 ```
41
35 -### Node Version Resolution
42 +### `DefineTestsContext`
43 +
44 +The context passed to the `defineTests` callback:
45 +
46 +| Function | Description |
47 +| -------------------------------- | ----------------------------------------------------------- |
48 +| `runCmd(command: string)` | Run arbitrary command in Docker container |
49 +| `runFixture(fixturePath: string)` | Run a fixture file with Node.js (equivalent to `runCmd(\`node ${path}\`)`) |
50 +
51 +### `E2ETestResult`
52 +
53 +Result returned by `runCmd` and `runFixture`:
54 +
55 +```typescript
56 +interface E2ETestResult {
57 + exitCode: number; // Exit code from the command (0 = success)
58 + stdout: string; // Captured stdout
59 + stderr: string; // Captured stderr
60 +}
61 +```
62 +
63 +### `sanitizeOutput`
64 +
65 +Utility for stable test comparisons. Removes ANSI escape codes, normalizes line endings, and trims whitespace.
66 +
67 +```typescript
68 +import { sanitizeOutput } from '@e2e-tests/utils';
69 +
70 +const clean = sanitizeOutput(result.stdout);
71 +```
72 +
73 +## Node Version Resolution
74
75 Node.js versions to test are resolved in this order:
76
@@ -40,14 +78,24 @@ Node.js versions to test are resolved in this order:
78 2. **`config.nodeVersions`**: Use the provided array
79 3. **Default**: Use `[process.versions.node]` (current runtime)
80
43 -### DEBUG.log
81 +### Well-Known Node Versions
82
45 -Each test run generates a `DEBUG.log` file in the test directory containing:
46 -- Test start timestamp
47 -- Node.js versions tested
48 -- stdout/stderr for each phase (setup and test)
49 -- Exit codes
50 -- Summary with pass/fail status
83 +The following versions are pre-defined in `const.ts`:
84 +
85 +- `20.18.0`
86 +- `20.19.0`
87 +- `22.12.0`
88 +- `current` (resolves to current Node runtime version)
89 +
90 +## Scripts
91 +
92 +```bash
93 +# Pre-build Docker images for all well-known Node versions
94 +pnpm docker:build
95 +
96 +# Remove all e2e Docker images
97 +pnpm docker:clean
98 +```
99
100 ## Behavior
101
ts/e2e-tests/runtimes/node/cjs-basic/README.md
-2
@@ -35,5 +35,3 @@ This ensures tests run against exact Node.js versions independent of the develop
35 ```bash
36 pnpm test:e2e
37 ```
38 -
39 -Debug output is written to `DEBUG.log`.
ts/e2e-tests/runtimes/node/esm-basic/README.md
-2
@@ -36,5 +36,3 @@ This ensures tests run against exact Node.js versions independent of the develop
36 ```bash
37 pnpm test:e2e
38 ```
39 -
40 -Debug output is written to `DEBUG.log`.
ts/e2e-tests/runtimes/node/openai-zod4-compat/README.md
-2
@@ -25,5 +25,3 @@ This ensures tests run against exact Node.js versions independent of the develop
25 ```bash
26 pnpm test:e2e
27 ```
28 -
29 -Debug output is written to `DEBUG.log`.
ts/e2e-tests/runtimes/node/openai-zod4-compat/e2e.test.ts
+13 -15
@@ -19,47 +19,45 @@ e2e(import.meta.url, {
19 env: {
20 COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
21 },
22 - defineTests: ({ runCmd, runFixture }) => {
23 - let setupResult: E2ETestResult;
24 - let testResult: E2ETestResult;
22 + defineTests: ({ runCmd }) => {
23 + let result: E2ETestResult;
24
25 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');
26 + result = await runCmd(
27 + 'npm --prefix fixtures install --legacy-peer-deps && node fixtures/index.mjs'
28 + );
29 });
30
31 describe('setup', () => {
32 it('npm install completes successfully', () => {
35 - expect(setupResult.exitCode).toBe(0);
33 + expect(result.stdout).toMatch(/added \d+ packages/);
34 });
35 });
36
37 describe('OpenAI v6 + Zod v4 compatibility', () => {
38 it('exits successfully', () => {
41 - expect(testResult.exitCode).toBe(0);
39 + expect(result.exitCode).toBe(0);
40 });
41
42 it('zod@4 works', () => {
45 - expect(testResult.stdout).toContain('zod@4 works');
43 + expect(result.stdout).toContain('zod@4 works');
44 });
45
46 it('openai@5 works', () => {
49 - expect(testResult.stdout).toContain('openai@5 works');
47 + expect(result.stdout).toContain('openai@5 works');
48 });
49
50 it('@composio/core works', () => {
53 - expect(testResult.stdout).toContain('@composio/core works');
51 + expect(result.stdout).toContain('@composio/core works');
52 });
53
54 it('wrapTool works', () => {
57 - expect(testResult.stdout).toContain('wrapTool works');
55 + expect(result.stdout).toContain('wrapTool works');
56 });
57
58 it('all packages work together', () => {
61 - expect(testResult.stdout).toContain('All packages work together!');
59 + expect(result.stdout).toContain('All packages work together!');
60 });
63 - });
61 + },);
62 },
63 });
ts/e2e-tests/runtimes/node/openai-zod4-compat/fixtures/package.json
+1 -1
@@ -2,7 +2,7 @@
2 "private": true,
3 "type": "module",
4 "dependencies": {
5 - "@composio/core": "workspace:*",
5 + "@composio/core": "file:/app/ts/packages/core",
6 "openai": "^6.16.0",
7 "zod": "^4.3.5"
8 }
ts/e2e-tests/runtimes/node/typescript-mjs-import-nodenext/README.md
+2 -4
@@ -24,9 +24,9 @@ This causes `TS2307: Cannot find module './foo.mjs'` errors.
24
25 ## Isolation Tool
26
27 -**Docker** with Node.js versions: 20.19.0, 22.12.0
27 +**Docker** with Node.js version: current runtime
28
29 -This ensures tests run against exact Node.js versions independent of the developer's local setup.
29 +This test uses the current Node.js runtime version for simplicity.
30
31 ## Running
32
@@ -34,8 +34,6 @@ This ensures tests run against exact Node.js versions independent of the develop
34 pnpm test:e2e
35 ```
36
37 -Debug output is written to `DEBUG.log`.
38 -
37 ## Expected Behavior
38
39 - **If bug exists (importExtension: 'mjs')**: TypeScript compilation fails with TS2307