@devries-cameron20 / composio-1 / commits / 63aa197d0
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.

feat(ts/e2e): add e2e tests for Deno

jkomyno committed Jan 30, 2026 at 21:19 UTC 63aa197d0f13f2b3d43533ba57882217c2f4932e
24 files changed +1257 -157
.dvmrc new
+1
@@ -0,0 +1 @@
1 +2.6.7
.github/workflows/ts.test-e2e.yml
+38 -15
@@ -41,23 +41,46 @@ jobs:
41 - name: Build
42 run: pnpm run build:packages
43
44 - - name: Verify API Key
45 - run: |
46 - if [ -z "$COMPOSIO_API_KEY" ]; then
47 - echo "::error::COMPOSIO_API_KEY is not set"
48 - exit 1
49 - fi
50 - echo "✅ COMPOSIO_API_KEY is configured"
51 - if [ -z "$OPENAI_API_KEY" ]; then
52 - echo "::error::OPENAI_API_KEY is not set"
53 - exit 1
54 - fi
55 - echo "✅ OPENAI_API_KEY is configured"
56 -
44 - name: Run Node.js E2E Tests
45 run: pnpm run test:e2e:node
59 - env:
60 - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
46 +
47 + # Deno E2E tests, running in Docker to isolate environment
48 + # Each test suite defines its own versions.deno in e2e.test.ts
49 + # Tests that don't support the matrix version are automatically skipped
50 + test-e2e-deno-docker:
51 + name: E2E Test Deno ${{ matrix.deno-version }}
52 + runs-on: ubuntu-24.04
53 + permissions: read-all
54 + strategy:
55 + fail-fast: false
56 + matrix:
57 + deno-version: ['2.6.7']
58 + env:
59 + CI: 1
60 + COMPOSIO_API_KEY: ${{ secrets.COMPOSIO_API_KEY }}
61 + COMPOSIO_E2E_DENO_VERSION: ${{ matrix.deno-version }}
62 + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
63 +
64 + steps:
65 + - name: Checkout Code
66 + uses: actions/checkout@v6
67 +
68 + - name: Setup Deno
69 + uses: denoland/setup-deno@v2
70 + with:
71 + deno-version: ${{ matrix.deno-version }}
72 +
73 + - name: Setup Node.js, pnpm, Bun
74 + uses: ./.github/actions/setup-node-pnpm-bun
75 +
76 + - name: Install Dependencies
77 + run: pnpm install --frozen-lockfile
78 +
79 + - name: Build
80 + run: pnpm run build:packages
81 +
82 + - name: Run Deno E2E Tests
83 + run: pnpm run test:e2e:deno
84
85 # Cloudflare Workerd E2E tests
86 test-e2e-cloudflare:
CLAUDE.md
+9 -1
@@ -196,17 +196,23 @@ pnpm test:ui
196 E2E tests for `@composio/core` are located in `ts/e2e-tests/` and test runtime compatibility across different JavaScript environments.
197
198 ```bash
199 -# Run all e2e tests (Node.js + Cloudflare)
199 +# Run all e2e tests (Node.js + Deno + Cloudflare)
200 pnpm test:e2e
201
202 # Run only Node.js e2e tests (CJS/ESM compatibility, runs in Docker)
203 pnpm test:e2e:node
204
205 +# Run only Deno e2e tests (npm: specifier compatibility, runs in Docker)
206 +pnpm test:e2e:deno
207 +
208 # Run only Cloudflare Workers e2e tests
209 pnpm test:e2e:cloudflare
210
211 # Run Node.js tests with a specific Node version
212 COMPOSIO_E2E_NODE_VERSION=22.12.0 pnpm test:e2e:node
213 +
214 +# Run Deno tests with a specific Deno version
215 +COMPOSIO_E2E_DENO_VERSION=2.6.7 pnpm test:e2e:deno
216 ```
217
218 **E2E Test Structure:**
@@ -217,6 +223,8 @@ ts/e2e-tests/
223 │ ├── node/ # Node.js runtime tests
224 │ │ ├── cjs-basic/ # CommonJS compatibility
225 │ │ └── esm-basic/ # ESM compatibility
226 +│ ├── deno/ # Deno runtime tests
227 +│ │ └── esm-basic/ # npm: specifier compatibility
228 │ └── cloudflare/ # Cloudflare runtime tests
229 │ └── cf-workers-basic/ # Cloudflare Workers tests
230 └── README.md # E2E test documentation
package.json
+1
@@ -15,6 +15,7 @@
15 "test": "turbo test --filter=./ts/packages/** --filter=!@e2e-tests/*",
16 "test:e2e": "turbo test:e2e --filter='@e2e-tests/*'",
17 "test:e2e:node": "turbo test:e2e:node --filter='@e2e-tests/node-*'",
18 + "test:e2e:deno": "turbo test:e2e:deno --filter='@e2e-tests/deno-*'",
19 "test:e2e:cloudflare": "turbo test:e2e:cloudflare --filter='@e2e-tests/cf-*'",
20 "test:ui": "vitest --ui",
21 "typecheck": "turbo typecheck --filter=./ts/packages/**",
pnpm-lock.yaml
+9
@@ -242,6 +242,15 @@ importers:
242 specifier: 'catalog:'
243 version: 4.60.0(@cloudflare/workers-types@4.20260124.0)
244
245 + ts/e2e-tests/runtimes/deno/esm-basic:
246 + devDependencies:
247 + '@composio/core':
248 + specifier: workspace:*
249 + version: link:../../../../packages/core
250 + '@e2e-tests/utils':
251 + specifier: workspace:*
252 + version: link:../../../_utils
253 +
254 ts/e2e-tests/runtimes/node/cjs-basic:
255 devDependencies:
256 '@composio/core':
pnpm-workspace.yaml
+1
@@ -1,6 +1,7 @@
1 packages:
2 - ts/e2e-tests/_utils
3 - ts/e2e-tests/runtimes/node/*
4 + - ts/e2e-tests/runtimes/deno/*
5 - ts/e2e-tests/runtimes/cloudflare/*
6 - ts/examples/*
7 - ts/packages/cli
ts/e2e-tests/README.md
+62 -5
@@ -8,12 +8,13 @@ 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 +│ ├── Dockerfile.deno # Docker image for Deno tests
12 │ ├── scripts/ # Docker build and cleanup scripts
12 -│ │ ├── docker-build.ts # Pre-build images for all Node versions
13 +│ │ ├── docker-build.ts # Pre-build images for all Node/Deno versions
14 │ │ └── docker-clean.ts # Remove all e2e Docker images
15 │ ├── src/ # TypeScript runner utilities
16 │ │ ├── config.ts # Configuration utilities
16 -│ │ ├── const.ts # Well-known Node.js versions and timeouts
17 +│ │ ├── const.ts # Well-known Node.js/Deno versions and timeouts
18 │ │ ├── e2e.ts # Main e2e test entry point
19 │ │ ├── image-lifecycle.ts # Docker image build/run utilities
20 │ │ ├── index.ts # Public exports
@@ -32,6 +33,8 @@ ts/e2e-tests/
33 │ ├── mastra-tool-router-zod-v4/ # @composio/mastra Tool Router + Zod v4 tests
34 │ ├── openai-zod4-compat/ # OpenAI + Zod v4 compatibility tests
35 │ └── typescript-mjs-import-nodenext/ # TypeScript moduleResolution: nodenext tests
36 + ├── deno/ # Deno runtime tests
37 + │ └── esm-basic/ # ESM compatibility tests via npm: specifier
38 └── cloudflare/ # Cloudflare runtime tests
39 ├── cf-workers-basic/ # Basic Cloudflare Workers tests
40 ├── cf-workers-files/ # Cloudflare Workers file handling tests
@@ -52,7 +55,7 @@ pnpm test:e2e
55 pnpm test:e2e:node
56 ```
57
55 -Runs Node.js tests in Docker using `bun test`. The default Node.js version is determined by the current runtime.
58 +Runs Node.js tests in Docker using `bun test`. The default Node.js version is determined by `.nvmrc`.
59
60 To run with a specific Node.js version:
61
@@ -60,6 +63,20 @@ To run with a specific Node.js version:
63 COMPOSIO_E2E_NODE_VERSION=22.12.0 pnpm test:e2e:node
64 ```
65
66 +### Deno Tests Only
67 +
68 +```bash
69 +pnpm test:e2e:deno
70 +```
71 +
72 +Runs Deno tests in Docker using `bun test`. The default Deno version is determined by `.dvmrc`.
73 +
74 +To run with a specific Deno version:
75 +
76 +```bash
77 +COMPOSIO_E2E_DENO_VERSION=2.6.7 pnpm test:e2e:deno
78 +```
79 +
80 ### Cloudflare Workers Tests Only
81
82 ```bash
@@ -80,9 +97,11 @@ import { e2e, type E2ETestResult } from '@e2e-tests/utils';
97 import { describe, it, expect, beforeAll } from 'bun:test';
98
99 e2e(import.meta.url, {
83 - nodeVersions: ['20.18.0', '22.12.0'], // Optional: defaults to current runtime
100 + versions: {
101 + node: ['20.18.0', '22.12.0'], // Optional: defaults to .nvmrc version
102 + },
103 env: { MY_VAR: process.env.MY_VAR }, // Optional: env vars (validated at startup)
85 - defineTests: ({ runFixture }) => {
104 + defineTests: ({ runtime, runFixture }) => {
105 let result: E2ETestResult;
106
107 beforeAll(async () => {
@@ -104,6 +123,44 @@ e2e(import.meta.url, {
123
124 5. Add fixture files in a `fixtures/` directory
125
126 +### Deno Runtime Tests
127 +
128 +1. Create a new directory under `runtimes/deno/` (e.g., `runtimes/deno/my-test`)
129 +2. Add a `package.json` with name `@e2e-tests/deno-my-test`
130 +3. Add `test:e2e` and `test:e2e:deno` scripts
131 +4. Create an `e2e.test.ts` file with inline configuration:
132 +
133 +```typescript
134 +import { e2e, type E2ETestResult } from '@e2e-tests/utils';
135 +import { describe, it, expect, beforeAll } from 'bun:test';
136 +
137 +e2e(import.meta.url, {
138 + versions: {
139 + deno: ['2.6.7'], // Optional: defaults to .dvmrc version
140 + },
141 + usesFixtures: true,
142 + defineTests: ({ runtime, runFixture }) => {
143 + let result: E2ETestResult;
144 +
145 + beforeAll(async () => {
146 + result = await runFixture({ filename: 'test.ts' });
147 + });
148 +
149 + describe('output', () => {
150 + it('exits successfully', () => {
151 + expect(result.exitCode).toBe(0);
152 + });
153 +
154 + it('contains expected output', () => {
155 + expect(result.stdout).toContain('expected text');
156 + });
157 + });
158 + },
159 +});
160 +```
161 +
162 +5. Add fixture files in a `fixtures/` directory. Fixtures use Deno's `npm:` specifier to import packages.
163 +
164 ### Tests with External Dependencies (npm install)
165
166 For tests that need to install npm packages at runtime, use `usesFixtures: true` and the `setup` option:
ts/e2e-tests/_utils/Dockerfile.deno new
+80
@@ -0,0 +1,80 @@
1 +# syntax=docker/dockerfile:1
2 +# Reusable Dockerfile for Deno e2e tests
3 +# Usage: docker build -f Dockerfile.deno --build-arg DENO_VERSION=2.6.7 -t test-name .
4 +#
5 +# Uses official denoland/deno images. For multi-version testing, run the build/run
6 +# multiple times with different DENO_VERSION values from the shell script.
7 +
8 +ARG DENO_VERSION=2.6.7
9 +
10 +FROM denoland/deno:${DENO_VERSION}
11 +
12 +ENV PNPM_HOME="/pnpm"
13 +ENV BUN_INSTALL="/usr/local"
14 +ENV PATH="$BUN_INSTALL/bin:$PNPM_HOME:$PATH"
15 +
16 +# Switch to root for installation
17 +USER root
18 +
19 +WORKDIR /app
20 +
21 +# Install system dependencies with cache mounts
22 +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
23 + --mount=type=cache,target=/var/lib/apt,sharing=locked \
24 + apt-get update && \
25 + apt-get install -y --no-install-recommends ca-certificates curl unzip && \
26 + rm -rf /var/lib/apt/lists/*
27 +
28 +# Install Node.js (needed for pnpm and building packages)
29 +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
30 + apt-get install -y nodejs && \
31 + rm -rf /var/lib/apt/lists/*
32 +
33 +# Install corepack (for pnpm) with npm cache mount
34 +RUN --mount=type=cache,target=/root/.npm \
35 + npm i -g corepack@latest && \
36 + corepack enable
37 +
38 +# Install bun (version from .bun-version)
39 +COPY .bun-version ./
40 +RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash -s "bun-v$(cat .bun-version)" && \
41 + bun --version
42 +
43 +# Copy lockfile first for optimal layer caching
44 +COPY pnpm-lock.yaml ./
45 +
46 +# Copy workspace configuration files
47 +COPY package.json \
48 + pnpm-workspace.yaml \
49 + .pnpmfile.cjs \
50 + tsconfig.base.json \
51 + tsdown.config.base.ts \
52 + ./
53 +
54 +# Copy pre-install scripts (rarely change)
55 +COPY ts/scripts/pre-install.sh ./ts/scripts/pre-install.sh
56 +COPY ts/scripts/pre-install/ ./ts/scripts/pre-install/
57 +
58 +# Copy all ts/packages (pre-built)
59 +COPY ts/packages/ ./ts/packages/
60 +
61 +# Install dependencies using pnpm
62 +# Note: We intentionally don't use --mount=type=cache for the pnpm store here
63 +# because it causes native binding issues (e.g., rolldown-binding) across builds
64 +RUN pnpm install --frozen-lockfile
65 +
66 +# Copy e2e tests last (changes frequently)
67 +COPY ts/e2e-tests/ ./ts/e2e-tests/
68 +
69 +# Create deno user and group (to match the official image's user)
70 +RUN groupadd -g 1000 deno 2>/dev/null || true && \
71 + useradd -u 1000 -g deno -m deno 2>/dev/null || true && \
72 + chown -R deno:deno /app
73 +
74 +# Pre-create Deno cache directory
75 +ENV DENO_DIR="/home/deno/.cache/deno"
76 +RUN mkdir -p $DENO_DIR && chown -R deno:deno /home/deno
77 +
78 +USER deno
79 +
80 +CMD ["sh"]
ts/e2e-tests/_utils/README.md
+42 -12
@@ -9,6 +9,7 @@ Shared infrastructure for running `@composio/core` end-to-end tests in isolated
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 +| `Dockerfile.deno` | Dockerfile for Deno test environments |
13
14 ## API
15
@@ -21,9 +22,12 @@ import { e2e, type E2ETestResult } from '@e2e-tests/utils';
22 import { describe, it, expect, beforeAll } from 'bun:test';
23
24 e2e(import.meta.url, {
24 - nodeVersions: ['20.18.0', '20.19.0', '22.12.0'], // optional
25 - env: { MY_VAR: 'value' }, // optional env vars
26 - defineTests: ({ runCmd, runFixture }) => {
25 + versions: {
26 + node: ['20.18.0', '20.19.0', '22.12.0'], // optional, defaults to .nvmrc
27 + deno: ['2.6.7'], // optional, defaults to .dvmrc
28 + },
29 + env: { MY_VAR: 'value' }, // optional env vars
30 + defineTests: ({ runtime, runCmd, runFixture }) => {
31 let result: E2ETestResult;
32
33 beforeAll(async () => {
@@ -45,17 +49,26 @@ Configuration object passed to `e2e()`:
49
50 | Property | Type | Description |
51 | -------------- | ------------------------------------- | ---------------------------------------------------------------- |
48 -| `nodeVersions` | `readonly NodeVersionFromUser[]` | Node.js versions to test. Defaults to current runtime |
52 +| `versions` | `RuntimeVersions` | Runtime versions to test. See RuntimeVersions below |
53 +| `nodeVersions` | `readonly NodeVersionFromUser[]` | **Deprecated.** Use `versions.node` instead |
54 | `env` | `Record<string, string \| undefined>` | Environment variables for Docker. Validated at startup |
55 | `usesFixtures` | `boolean` | When true, sets cwd to `{testDir}/fixtures`. Default: `false` |
56 | `defineTests` | `(ctx: DefineTestsContext) => void` | Callback to define tests using bun:test primitives |
57
58 +### `RuntimeVersions`
59 +
60 +| Property | Type | Description |
61 +| -------- | -------------------------------- | ------------------------------------------------ |
62 +| `node` | `readonly NodeVersionFromUser[]` | Node.js versions. Defaults to `.nvmrc` |
63 +| `deno` | `readonly DenoVersionFromUser[]` | Deno versions. Defaults to `.dvmrc` |
64 +
65 ### `DefineTestsContext`
66
67 The context passed to the `defineTests` callback:
68
57 -| Function | Signature | Description |
69 +| Property | Type/Signature | Description |
70 | ------------ | ---------------------------------------------------------------- | ---------------------------------------------- |
71 +| `runtime` | `'node' \| 'deno'` | Current runtime being tested |
72 | `runCmd` | `(command: string) => Promise<E2ETestResult>` | Run arbitrary command in Docker container |
73 | `runFixture` | `(options: RunFixtureOptions) => Promise<E2ETestResult \| E2ETestResultWithSetup>` | Run fixture with optional setup phase |
74
@@ -142,13 +155,15 @@ it('calls LLM', async () => {
155 | `LLM_SHORT` | `15_000` | Quick LLM calls |
156 | `LLM_LONG` | `60_000` | Complex LLM operations |
157
145 -## Node Version Resolution
158 +## Version Resolution
159 +
160 +### Node.js Version Resolution
161
162 Node.js versions to test are resolved in this order:
163
164 1. **`COMPOSIO_E2E_NODE_VERSION` env var** (highest priority): Use `[env_value]`
150 -2. **`config.nodeVersions`**: Use the provided array
151 -3. **Default**: Use `[process.versions.node]` (current runtime)
165 +2. **`config.versions.node`** or **`config.nodeVersions`**: Use the provided array
166 +3. **Default**: Use version from `.nvmrc` file
167
168 ### Well-Known Node Versions
169
@@ -157,7 +172,22 @@ The following versions are pre-defined in `const.ts`:
172 - `20.18.0`
173 - `20.19.0`
174 - `22.12.0`
160 -- `current` (resolves to current Node runtime version)
175 +- `current` (resolves to `.nvmrc` version)
176 +
177 +### Deno Version Resolution
178 +
179 +Deno versions to test are resolved in this order:
180 +
181 +1. **`COMPOSIO_E2E_DENO_VERSION` env var** (highest priority): Use `[env_value]`
182 +2. **`config.versions.deno`**: Use the provided array
183 +3. **Default**: Use version from `.dvmrc` file
184 +
185 +### Well-Known Deno Versions
186 +
187 +The following versions are pre-defined in `const.ts`:
188 +
189 +- `2.6.7`
190 +- `current` (resolves to `.dvmrc` version)
191
192 ## Environment Variable Validation
193
@@ -198,16 +228,16 @@ e2e(import.meta.url, {
228 ## Scripts
229
230 ```bash
201 -# Pre-build Docker images for all well-known Node versions
231 +# Pre-build Docker images for all well-known Node and Deno versions
232 pnpm docker:build
233
204 -# Remove all e2e Docker images
234 +# Remove all e2e Docker images (both Node.js and Deno)
235 pnpm docker:clean
236 ```
237
238 ## DEBUG.log Output
239
210 -Each test suite generates a `DEBUG.log` file with structured output grouped by Node version:
240 +Each test suite generates a `DEBUG.log` file with structured output grouped by runtime version:
241
242 ```
243 ================================================================================
ts/e2e-tests/_utils/scripts/docker-build.ts
+131 -28
@@ -1,18 +1,19 @@
1 #!/usr/bin/env bun
2 /**
3 - * Builds Docker images for Node.js e2e tests.
3 + * Builds Docker images for Node.js and Deno e2e tests.
4 *
5 - * In CI mode (COMPOSIO_E2E_NODE_VERSION set):
5 + * In CI mode (COMPOSIO_E2E_NODE_VERSION or COMPOSIO_E2E_DENO_VERSION set):
6 * Only builds the image for the specified version.
7 *
8 * In local mode:
9 - * Builds images for all versions in WELL_KNOWN_NODE_VERSIONS.
9 + * Builds images for all versions in WELL_KNOWN_NODE_VERSIONS and WELL_KNOWN_DENO_VERSIONS.
10 */
11
12 import { $ } from 'bun';
13 import { resolve, dirname } from 'node:path';
14 import { fileURLToPath } from 'node:url';
15 -import { WELL_KNOWN_NODE_VERSIONS } from '../src/const';
15 +import { readFileSync } from 'node:fs';
16 +import { WELL_KNOWN_NODE_VERSIONS, WELL_KNOWN_DENO_VERSIONS } from '../src/const';
17
18 const __dirname = dirname(fileURLToPath(import.meta.url));
19
@@ -21,11 +22,31 @@ function getRepoRoot(): string {
22 return resolve(__dirname, '../../../..');
23 }
24
25 +function getNvmrcVersion(repoRoot: string): string {
26 + try {
27 + return readFileSync(resolve(repoRoot, '.nvmrc'), 'utf-8').trim();
28 + } catch {
29 + return process.versions.node;
30 + }
31 +}
32 +
33 +function getDvmrcVersion(repoRoot: string): string {
34 + try {
35 + return readFileSync(resolve(repoRoot, '.dvmrc'), 'utf-8').trim();
36 + } catch {
37 + return '2.6.7'; // fallback default
38 + }
39 +}
40 +
41 +// ============================================================================
42 +// Node.js image building
43 +// ============================================================================
44 +
45 function imageTagForNodeVersion(nodeVersion: string): string {
46 return `composio-e2e-node:${nodeVersion}`;
47 }
48
28 -function defaultLabels(nodeVersion: string): Record<string, string> {
49 +function defaultNodeLabels(nodeVersion: string): Record<string, string> {
50 return {
51 'composio.e2e': 'true',
52 'composio.runtime': 'node',
@@ -33,10 +54,10 @@ function defaultLabels(nodeVersion: string): Record<string, string> {
54 };
55 }
56
36 -async function buildImage(nodeVersion: string, repoRoot: string): Promise<boolean> {
57 +async function buildNodeImage(nodeVersion: string, repoRoot: string): Promise<boolean> {
58 const dockerfilePath = resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.node');
59 const imageTag = imageTagForNodeVersion(nodeVersion);
39 - const labels = defaultLabels(nodeVersion);
60 + const labels = defaultNodeLabels(nodeVersion);
61 const labelArgs = Object.entries(labels)
62 .map(([k, v]) => `--label=${k}=${v}`)
63 .join(' ');
@@ -57,45 +78,127 @@ async function buildImage(nodeVersion: string, repoRoot: string): Promise<boolea
78 return true;
79 }
80
60 -async function main() {
61 - const repoRoot = getRepoRoot();
62 - const currentNodeVersion = process.versions.node;
63 - const envVersion = Bun.env.COMPOSIO_E2E_NODE_VERSION;
81 +// ============================================================================
82 +// Deno image building
83 +// ============================================================================
84 +
85 +function imageTagForDenoVersion(denoVersion: string): string {
86 + return `composio-e2e-deno:${denoVersion}`;
87 +}
88 +
89 +function defaultDenoLabels(denoVersion: string): Record<string, string> {
90 + return {
91 + 'composio.e2e': 'true',
92 + 'composio.runtime': 'deno',
93 + 'composio.deno_version': denoVersion,
94 + };
95 +}
96 +
97 +async function buildDenoImage(denoVersion: string, repoRoot: string): Promise<boolean> {
98 + const dockerfilePath = resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.deno');
99 + const imageTag = imageTagForDenoVersion(denoVersion);
100 + const labels = defaultDenoLabels(denoVersion);
101 + const labelArgs = Object.entries(labels)
102 + .map(([k, v]) => `--label=${k}=${v}`)
103 + .join(' ');
104 +
105 + console.log(`\nBuilding image for Deno ${denoVersion}...`);
106 +
107 + const result = await $`docker build -f ${dockerfilePath} --build-arg DENO_VERSION=${denoVersion} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`
108 + .cwd(repoRoot)
109 + .nothrow();
110 +
111 + if (result.exitCode !== 0) {
112 + console.error(` Failed to build ${imageTag}:`);
113 + console.error(result.stderr.toString() || result.stdout.toString());
114 + return false;
115 + }
116
65 - // In CI mode with COMPOSIO_E2E_NODE_VERSION set, only build that specific version
66 - // Otherwise, build all well-known versions (for local development)
67 - const versions = new Set<string>();
117 + console.log(` Built ${imageTag}`);
118 + return true;
119 +}
120 +
121 +// ============================================================================
122 +// Main
123 +// ============================================================================
124
69 - if (envVersion) {
70 - versions.add(envVersion);
71 - console.log(`Building Docker image for CI matrix version: ${envVersion}`);
72 - } else {
125 +async function main() {
126 + const repoRoot = getRepoRoot();
127 + const currentNodeVersion = getNvmrcVersion(repoRoot);
128 + const currentDenoVersion = getDvmrcVersion(repoRoot);
129 + const envNodeVersion = Bun.env.COMPOSIO_E2E_NODE_VERSION;
130 + const envDenoVersion = Bun.env.COMPOSIO_E2E_DENO_VERSION;
131 +
132 + const nodeVersions = new Set<string>();
133 + const denoVersions = new Set<string>();
134 +
135 + // Determine which Node.js versions to build
136 + if (envNodeVersion) {
137 + nodeVersions.add(envNodeVersion);
138 + console.log(`Building Docker image for CI matrix Node.js version: ${envNodeVersion}`);
139 + } else if (!envDenoVersion) {
140 + // Build all Node.js versions only if no specific runtime was requested
141 for (const version of WELL_KNOWN_NODE_VERSIONS) {
142 if (version === 'current') {
75 - versions.add(currentNodeVersion);
143 + nodeVersions.add(currentNodeVersion);
144 } else {
77 - versions.add(version);
145 + nodeVersions.add(version);
146 }
147 }
80 - console.log('Building Docker images for Node.js versions:');
81 - for (const v of versions) {
82 - const isCurrent = v === currentNodeVersion ? ' (current)' : '';
83 - console.log(` - ${v}${isCurrent}`);
148 + if (nodeVersions.size > 0) {
149 + console.log('Building Docker images for Node.js versions:');
150 + for (const v of nodeVersions) {
151 + const isCurrent = v === currentNodeVersion ? ' (current)' : '';
152 + console.log(` - ${v}${isCurrent}`);
153 + }
154 }
155 }
156
87 - const versionList = Array.from(versions);
157 + // Determine which Deno versions to build
158 + if (envDenoVersion) {
159 + denoVersions.add(envDenoVersion);
160 + console.log(`Building Docker image for CI matrix Deno version: ${envDenoVersion}`);
161 + } else if (!envNodeVersion) {
162 + // Build all Deno versions only if no specific runtime was requested
163 + for (const version of WELL_KNOWN_DENO_VERSIONS) {
164 + if (version === 'current') {
165 + denoVersions.add(currentDenoVersion);
166 + } else {
167 + denoVersions.add(version);
168 + }
169 + }
170 + if (denoVersions.size > 0) {
171 + console.log('Building Docker images for Deno versions:');
172 + for (const v of denoVersions) {
173 + const isCurrent = v === currentDenoVersion ? ' (current)' : '';
174 + console.log(` - ${v}${isCurrent}`);
175 + }
176 + }
177 + }
178
179 let failed = 0;
90 - for (const version of versionList) {
91 - const success = await buildImage(version, repoRoot);
180 + let total = 0;
181 +
182 + // Build Node.js images
183 + for (const version of nodeVersions) {
184 + total++;
185 + const success = await buildNodeImage(version, repoRoot);
186 + if (!success) {
187 + failed++;
188 + }
189 + }
190 +
191 + // Build Deno images
192 + for (const version of denoVersions) {
193 + total++;
194 + const success = await buildDenoImage(version, repoRoot);
195 if (!success) {
196 failed++;
197 }
198 }
199
200 console.log('\n---');
98 - console.log(`Built ${versionList.length - failed}/${versionList.length} images.`);
201 + console.log(`Built ${total - failed}/${total} images.`);
202
203 if (failed > 0) {
204 process.exit(1);
ts/e2e-tests/_utils/scripts/docker-clean.ts
+24 -12
@@ -1,22 +1,22 @@
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`.
3 + * Removes all Docker images used by Node.js and Deno e2e tests.
4 + * Images are identified by the label `composio.e2e=true`.
5 */
6
7 import { $ } from 'bun';
8
9 -async function main() {
10 - console.log('Finding e2e Node.js Docker images...');
9 +async function cleanImages(runtime: 'node' | 'deno'): Promise<number> {
10 + console.log(`Finding e2e ${runtime === 'node' ? 'Node.js' : 'Deno'} 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}}`
13 + const result = await $`docker images --filter label=composio.e2e=true --filter label=composio.runtime=${runtime} --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);
18 + console.error(`Failed to list Docker images:`, result.stderr.toString());
19 + return 1;
20 }
21
22 const images = result.stdout
@@ -26,8 +26,8 @@ async function main() {
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;
29 + console.log(`No e2e ${runtime === 'node' ? 'Node.js' : 'Deno'} Docker images found.`);
30 + return 0;
31 }
32
33 console.log(`Found ${images.length} image(s) to remove:`);
@@ -47,12 +47,24 @@ async function main() {
47 }
48 }
49
50 - if (removeFailures > 0) {
51 - console.error(`Failed to remove ${removeFailures} image(s).`);
50 + return removeFailures;
51 +}
52 +
53 +async function main() {
54 + let totalFailures = 0;
55 +
56 + // Clean Node.js images
57 + totalFailures += await cleanImages('node');
58 +
59 + // Clean Deno images
60 + totalFailures += await cleanImages('deno');
61 +
62 + if (totalFailures > 0) {
63 + console.error(`\nFailed to remove ${totalFailures} image(s).`);
64 process.exit(1);
65 }
66
55 - console.log('Done.');
67 + console.log('\nDone.');
68 }
69
70 main().catch((err) => {
ts/e2e-tests/_utils/src/config.ts
+79 -1
@@ -2,12 +2,13 @@ import { dirname, resolve } from 'node:path';
2 import { fileURLToPath } from 'node:url';
3 import { readFileSync } from 'node:fs';
4 import process from 'node:process';
5 -import type { NodeVersionMeta, NodeVersionFromUser, SkipInCI, NonEmptyArray } from './types';
5 +import type { NodeVersionMeta, NodeVersionFromUser, DenoVersionMeta, DenoVersionFromUser, SkipInCI, NonEmptyArray } from './types';
6
7 declare module 'bun' {
8 interface Env {
9 CI?: string;
10 COMPOSIO_E2E_NODE_VERSION?: string;
11 + COMPOSIO_E2E_DENO_VERSION?: string;
12 }
13 }
14
@@ -104,3 +105,80 @@ export function getNvmrcVersion(): string {
105 }
106 }
107
108 +/**
109 + * Read the Deno version from .dvmrc file.
110 + * Used to determine the version for 'current' tests.
111 + *
112 + * @throws Error if .dvmrc file does not exist
113 + */
114 +export function getDvmrcVersion(): string {
115 + try {
116 + const dvmrc = readFileSync(resolve(getRepoRoot(), '.dvmrc'), 'utf-8');
117 + return dvmrc.trim();
118 + } catch {
119 + throw new Error(
120 + 'Failed to read .dvmrc for Deno version resolution. ' +
121 + 'Create a .dvmrc file at the repo root with the desired Deno version (e.g., "2.6.7").'
122 + );
123 + }
124 +}
125 +
126 +/**
127 + * Compute skip state for a Deno version in CI mode.
128 + */
129 +function computeSkipForDenoVersion(
130 + envVersion: string | undefined,
131 + versionValue: string
132 +): SkipInCI {
133 + if (!isCI() || !envVersion) {
134 + return { value: false };
135 + }
136 +
137 + if (versionValue !== envVersion) {
138 + return {
139 + value: true,
140 + reason: `Deno ${versionValue} not selected (running ${envVersion})`,
141 + };
142 + }
143 +
144 + return { value: false };
145 +}
146 +
147 +/**
148 + * Resolve the Deno versions to test against, with CI skip state.
149 + *
150 + * The `'current'` version always resolves to the value in `.dvmrc`.
151 + *
152 + * In CI mode (CI env var set + COMPOSIO_E2E_DENO_VERSION set):
153 + * - Versions not matching COMPOSIO_E2E_DENO_VERSION are marked to skip
154 + *
155 + * In local mode:
156 + * - COMPOSIO_E2E_DENO_VERSION overrides everything (single version, no skip)
157 + * - Otherwise returns all configured versions (no skip)
158 + */
159 +export function resolveDenoVersionMetaList(
160 + configDenoVersions?: readonly DenoVersionFromUser[]
161 +): NonEmptyArray<DenoVersionMeta> {
162 + const envVersion = Bun.env.COMPOSIO_E2E_DENO_VERSION;
163 + const dvmrcVersion = getDvmrcVersion();
164 +
165 + // Local mode with env override: single version, no skip
166 + if (!isCI() && envVersion) {
167 + return [{ kind: 'overridden', value: envVersion, skip: { value: false } }];
168 + }
169 +
170 + // No config provided: use .dvmrc version
171 + if (configDenoVersions === undefined || configDenoVersions.length === 0) {
172 + return [{ kind: 'current', value: dvmrcVersion, skip: { value: false } }];
173 + }
174 +
175 + const resolvedVersions = configDenoVersions.map((v): DenoVersionMeta => {
176 + if (v === 'current') {
177 + return { kind: 'current', value: dvmrcVersion, skip: computeSkipForDenoVersion(envVersion, dvmrcVersion) };
178 + }
179 + return { kind: 'static', value: v, skip: computeSkipForDenoVersion(envVersion, v) };
180 + });
181 +
182 + return resolvedVersions as NonEmptyArray<DenoVersionMeta>;
183 +}
184 +
ts/e2e-tests/_utils/src/const.ts
+6
@@ -9,6 +9,12 @@ export const WELL_KNOWN_ENV_VARS = ['COMPOSIO_API_KEY', 'OPENAI_API_KEY'] as con
9 */
10 export const WELL_KNOWN_NODE_VERSIONS = ['20.18.0', '20.19.0', '22.12.0', 'current'] as const;
11
12 +/**
13 + * Deno versions that are well-known to the CI matrix strategy.
14 + * `current` refers to the Deno version specified in `.dvmrc`.
15 + */
16 +export const WELL_KNOWN_DENO_VERSIONS = ['2.6.7', 'current'] as const;
17 +
18 export const TIMEOUTS = {
19 DEFAULT: 5_000,
20 LLM_SHORT: 15_000,
ts/e2e-tests/_utils/src/image-lifecycle.ts
+183 -4
@@ -79,9 +79,9 @@ function escapeShellArg(arg: string): string {
79 }
80
81 /**
82 - * Creates default Docker labels for e2e images.
82 + * Creates default Docker labels for Node.js e2e images.
83 */
84 -function defaultLabels(nodeVersion?: string): Record<string, string> {
84 +function defaultNodeLabels(nodeVersion?: string): Record<string, string> {
85 const labels: Record<string, string> = {
86 'composio.e2e': 'true',
87 'composio.runtime': 'node',
@@ -92,6 +92,20 @@ function defaultLabels(nodeVersion?: string): Record<string, string> {
92 return labels;
93 }
94
95 +/**
96 + * Creates default Docker labels for Deno e2e images.
97 + */
98 +function defaultDenoLabels(denoVersion?: string): Record<string, string> {
99 + const labels: Record<string, string> = {
100 + 'composio.e2e': 'true',
101 + 'composio.runtime': 'deno',
102 + };
103 + if (denoVersion) {
104 + labels['composio.deno_version'] = denoVersion;
105 + }
106 + return labels;
107 +}
108 +
109 /**
110 * Converts labels object to Docker CLI arguments array.
111 */
@@ -180,7 +194,7 @@ export async function ensureNodeImage(
194 dockerfilePath,
195 '--build-arg',
196 `NODE_VERSION=${nodeVersion}`,
183 - ...labelsToArgs(defaultLabels(nodeVersion)),
197 + ...labelsToArgs(defaultNodeLabels(nodeVersion)),
198 '-t',
199 imageTag,
200 repoRoot,
@@ -211,7 +225,7 @@ export async function runNodeContainer(options: RunNodeContainerOptions): Promis
225
226 const dockerArgs = ['run', '--rm'];
227
214 - dockerArgs.push(...labelsToArgs({ ...defaultLabels(nodeVersion), ...(labels ?? {}) }));
228 + dockerArgs.push(...labelsToArgs({ ...defaultNodeLabels(nodeVersion), ...(labels ?? {}) }));
229
230 // Assign a custom container name for easier identification and cleanup.
231 if (name) {
@@ -275,3 +289,168 @@ export async function runNodeContainer(options: RunNodeContainerOptions): Promis
289
290 return exec('docker', dockerArgs);
291 }
292 +
293 +// ============================================================================
294 +// Deno Docker utilities
295 +// ============================================================================
296 +
297 +/**
298 + * Options for running a Deno container.
299 + */
300 +export interface RunDenoContainerOptions {
301 + imageTag: string;
302 + cmd: string | string[];
303 + cwd?: string;
304 + mounts?: DockerMount[];
305 + /** Named volume mounts (volumes must be created beforehand with `docker volume create`) */
306 + volumes?: DockerVolumeMount[];
307 + env?: Record<string, string | undefined>;
308 + labels?: Record<string, string>;
309 + name?: string;
310 +}
311 +
312 +/**
313 + * Options for ensureDenoImage.
314 + */
315 +export interface EnsureDenoImageOptions {
316 + repoRoot?: string;
317 + dockerfilePath?: string;
318 +}
319 +
320 +/**
321 + * Creates image tag for a given Deno version.
322 + */
323 +function imageTagForDenoVersion(denoVersion: string): string {
324 + return `composio-e2e-deno:${denoVersion}`;
325 +}
326 +
327 +/**
328 + * Parses Deno version from an image tag.
329 + */
330 +function parseDenoVersionFromImageTag(imageTag: string): string | undefined {
331 + const match = /^composio-e2e-deno:(.+)$/.exec(imageTag);
332 + return match?.[1];
333 +}
334 +
335 +/**
336 + * Ensures a Docker image exists for the given Deno version, building it if necessary.
337 + */
338 +export async function ensureDenoImage(
339 + denoVersion: string,
340 + options: EnsureDenoImageOptions = {}
341 +): Promise<string> {
342 + if (!denoVersion || typeof denoVersion !== 'string') {
343 + throw new Error(`ensureDenoImage(${denoVersion}): denoVersion must be a non-empty string`);
344 + }
345 +
346 + const repoRoot = options.repoRoot ?? getRepoRoot();
347 + const dockerfilePath = options.dockerfilePath ?? resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.deno');
348 + const imageTag = imageTagForDenoVersion(denoVersion);
349 +
350 + const inspect = await exec('docker', ['image', 'inspect', imageTag], { cwd: repoRoot });
351 + if (inspect.exitCode === 0) {
352 + return imageTag;
353 + }
354 +
355 + const buildArgs = [
356 + 'build',
357 + '-f',
358 + dockerfilePath,
359 + '--build-arg',
360 + `DENO_VERSION=${denoVersion}`,
361 + ...labelsToArgs(defaultDenoLabels(denoVersion)),
362 + '-t',
363 + imageTag,
364 + repoRoot,
365 + ];
366 +
367 + const built = await exec('docker', buildArgs, { cwd: repoRoot });
368 + if (built.exitCode !== 0) {
369 + const err = new Error(`Failed to build Docker image ${imageTag}`);
370 + (err as Error & { cause: Error }).cause = new Error(built.stderr || built.stdout);
371 + throw err;
372 + }
373 +
374 + return imageTag;
375 +}
376 +
377 +/**
378 + * Runs a command in a Deno Docker container.
379 + */
380 +export async function runDenoContainer(options: RunDenoContainerOptions): Promise<ExecResult> {
381 + const { imageTag, cmd, cwd, mounts, volumes, env, labels, name } = options;
382 +
383 + // Validate imageTag is provided, as it determines which Docker image to run.
384 + if (!imageTag || typeof imageTag !== 'string') {
385 + throw new Error('runDenoContainer({ imageTag, ... }): imageTag must be a non-empty string');
386 + }
387 +
388 + const denoVersion = parseDenoVersionFromImageTag(imageTag);
389 +
390 + const dockerArgs = ['run', '--rm'];
391 +
392 + dockerArgs.push(...labelsToArgs({ ...defaultDenoLabels(denoVersion), ...(labels ?? {}) }));
393 +
394 + // Assign a custom container name for easier identification and cleanup.
395 + if (name) {
396 + dockerArgs.push('--name', name);
397 + }
398 +
399 + // Set the working directory inside the container, defaulting relative paths to /app.
400 + if (cwd) {
401 + const containerCwd = cwd.startsWith('/') ? cwd : `/app/${cwd}`;
402 + dockerArgs.push('--workdir', containerCwd);
403 + }
404 +
405 + // Pass environment variables to the container for runtime configuration.
406 + if (env) {
407 + for (const [k, v] of Object.entries(env)) {
408 + // Skip undefined values to avoid passing empty env vars to Docker.
409 + if (v === undefined) continue;
410 + dockerArgs.push('-e', `${k}=${v}`);
411 + }
412 + }
413 +
414 + // Configure bind mounts to share host directories with the container.
415 + if (mounts) {
416 + for (const m of mounts) {
417 + // Ensure each mount has required source and target paths.
418 + if (!m?.source || !m?.target) {
419 + throw new Error('runDenoContainer(...): each mount must have { source, target }');
420 + }
421 + const parts = [`type=bind`, `src=${m.source}`, `dst=${m.target}`];
422 + // Mark mount as read-only to prevent container from modifying host files.
423 + if (m.readonly) parts.push('readonly');
424 + dockerArgs.push('--mount', parts.join(','));
425 + }
426 + }
427 +
428 + // Configure named volume mounts for sharing state between container runs.
429 + if (volumes) {
430 + for (const v of volumes) {
431 + // Ensure each volume mount has required volume name and target path.
432 + if (!v?.volume || !v?.target) {
433 + throw new Error('runDenoContainer(...): each volume must have { volume, target }');
434 + }
435 + const parts = [`type=volume`, `src=${v.volume}`, `dst=${v.target}`];
436 + // Mark mount as read-only if specified.
437 + if (v.readonly) parts.push('readonly');
438 + dockerArgs.push('--mount', parts.join(','));
439 + }
440 + }
441 +
442 + dockerArgs.push(imageTag);
443 +
444 + // Handle cmd as array for direct execution without shell interpretation.
445 + if (Array.isArray(cmd)) {
446 + dockerArgs.push(...cmd.map(String));
447 + // Handle cmd as string by wrapping in deno run with necessary permissions.
448 + } else if (typeof cmd === 'string' && cmd.length > 0) {
449 + // Use deno run with all permissions for e2e tests
450 + dockerArgs.push('sh', '-lc', `deno run --allow-all ${cmd}`);
451 + } else {
452 + throw new Error('runDenoContainer({ cmd, ... }): cmd must be a non-empty string or string[]');
453 + }
454 +
455 + return exec('docker', dockerArgs);
456 +}
ts/e2e-tests/_utils/src/index.ts
+12 -1
@@ -1,3 +1,14 @@
1 -export type { E2EConfig, E2ETestResult, E2ETestResultWithSetup, RunFixtureOptions, DefineTestsContext, NodeVersionMeta as NodeVersion, SkipInCI } from './types';
1 +export type {
2 + E2EConfig,
3 + E2ETestResult,
4 + E2ETestResultWithSetup,
5 + RunFixtureOptions,
6 + DefineTestsContext,
7 + NodeVersionMeta as NodeVersion,
8 + DenoVersionMeta as DenoVersion,
9 + RuntimeVersions,
10 + RuntimeKind,
11 + SkipInCI,
12 +} from './types';
13 export { e2e } from './e2e';
14 export { sanitizeOutput } from './sanitize';
ts/e2e-tests/_utils/src/runner.ts
+304 -77
@@ -1,9 +1,20 @@
1 import { describe, beforeAll, afterAll, it } from 'bun:test';
2 import { appendFile, writeFile } from 'node:fs/promises';
3 import { resolve } from 'node:path';
4 -import type { DefineTestsContext, E2EConfig, E2ETestResult, E2ETestResultWithSetup, NodeVersionMeta, NonEmptyString, RunFixtureOptions } from './types';
5 -import { getRepoRoot, resolveNodeVersionMetaList } from './config';
6 -import { ensureNodeImage, runNodeContainer } from './image-lifecycle';
4 +import type {
5 + DefineTestsContext,
6 + E2EConfig,
7 + E2ETestResult,
8 + E2ETestResultWithSetup,
9 + NodeVersionMeta,
10 + DenoVersionMeta,
11 + NonEmptyString,
12 + RunFixtureOptions,
13 + RuntimeVersions,
14 + RuntimeKind,
15 +} from './types';
16 +import { getRepoRoot, resolveNodeVersionMetaList, resolveDenoVersionMetaList } from './config';
17 +import { ensureNodeImage, runNodeContainer, ensureDenoImage, runDenoContainer } from './image-lifecycle';
18 import { WELL_KNOWN_ENV_VARS } from './const';
19 import { createVolume, generateVolumeName, initializeVolumeOwnership, removeVolume } from './volume';
20
@@ -27,9 +38,10 @@ interface PhaseResult {
38 }
39
40 /**
30 - * Aggregated results for a Node version.
41 + * Aggregated results for a runtime version.
42 */
43 interface VersionResult {
44 + runtime: RuntimeKind;
45 version: string;
46 status: 'pass' | 'fail' | 'skipped';
47 reason?: string;
@@ -45,12 +57,12 @@ interface DebugLogManagerOptions {
57 logPath: string;
58 suiteName: string;
59 testFilePath: string;
48 - nodeVersions: string[];
60 + runtimeVersions: string[];
61 }
62
63 /**
64 * Manages structured DEBUG.log output for e2e tests.
53 - * Clears the file at initialization, groups phases by Node version,
65 + * Clears the file at initialization, groups phases by runtime version,
66 * and writes a summary at the end.
67 */
68 class DebugLogManager {
@@ -103,7 +115,7 @@ class DebugLogManager {
115 `E2E Test: ${this.options.suiteName}`,
116 `Started: ${this.startTime.toISOString()}`,
117 `Test file: ${this.options.testFilePath}`,
106 - `Node versions: ${this.options.nodeVersions.join(', ')}`,
118 + `Runtime versions: ${this.options.runtimeVersions.join(', ')}`,
119 divider,
120 '',
121 ].join('\n');
@@ -111,10 +123,11 @@ class DebugLogManager {
123
124 private formatVersionSection(result: VersionResult): string {
125 const dividerHeavy = '#'.repeat(80);
126 + const runtimeLabel = result.runtime === 'node' ? 'Node.js' : 'Deno';
127 const lines: string[] = [
128 '',
129 dividerHeavy,
117 - `### Node.js ${result.version}${result.status === 'skipped' ? ' (SKIPPED)' : ''}`,
130 + `### ${runtimeLabel} ${result.version}${result.status === 'skipped' ? ' (SKIPPED)' : ''}`,
131 dividerHeavy,
132 ];
133
@@ -168,15 +181,16 @@ class DebugLogManager {
181 ];
182
183 for (const result of this.versionResults) {
184 + const runtimeLabel = result.runtime === 'node' ? 'Node.js' : 'Deno';
185 if (result.status === 'skipped') {
172 - lines.push(`Node.js ${result.version}: SKIPPED`);
186 + lines.push(`${runtimeLabel} ${result.version}: SKIPPED`);
187 } else {
188 const status = result.status.toUpperCase();
189 const phaseCount = result.phases.length;
190 const versionDurationSec = result.totalDurationMs
191 ? (result.totalDurationMs / 1000).toFixed(2)
192 : '?';
179 - lines.push(`Node.js ${result.version}: ${status} (${phaseCount} phases, ${versionDurationSec}s total)`);
193 + lines.push(`${runtimeLabel} ${result.version}: ${status} (${phaseCount} phases, ${versionDurationSec}s total)`);
194 }
195 }
196
@@ -190,6 +204,11 @@ class DebugLogManager {
204 }
205 }
206
207 +// ============================================================================
208 +// Container environment utilities
209 +// ============================================================================
210 +
211 +
212 /**
213 * Builds environment variables to pass to the container.
214 * Merges auto-passthrough vars with explicitly provided env vars.
@@ -256,11 +275,14 @@ interface VersionExecutionContext {
275 imageTag: string;
276 }
277
278 +// ============================================================================
279 +// Node.js Docker Executors
280 +// ============================================================================
281 +
282 /**
260 - * Creates Docker execution utilities for a specific Node version.
261 - * Now tracks phase results for the DebugLogManager.
283 + * Creates Docker execution utilities for a specific Node.js version.
284 */
263 -function createDockerExecutors(
285 +function createNodeDockerExecutors(
286 config: RunE2EInternalConfig,
287 nodeVersion: string,
288 imageTag: string,
@@ -269,11 +291,8 @@ function createDockerExecutors(
291 ) {
292 const { cwd, suiteName, env, usesFixtures } = config;
293 const containerEnv = buildContainerEnv(env);
272 -
273 - // Compute effective cwd based on usesFixtures flag
294 const effectiveCwd = usesFixtures ? `${cwd}/fixtures` : cwd;
295
276 - // Track execution context for this version
296 const context: VersionExecutionContext = {
297 phases: [],
298 versionStartTime: Date.now(),
@@ -281,7 +300,7 @@ function createDockerExecutors(
300 };
301
302 const runCmd = async (command: string): Promise<E2ETestResult> => {
284 - const containerName = `e2e-${suiteName}-${nodeVersion.replace(/\./g, '-')}-${Date.now()}`;
303 + const containerName = `e2e-${suiteName}-node-${nodeVersion.replace(/\./g, '-')}-${Date.now()}`;
304 const startTime = Date.now();
305
306 const result = await runNodeContainer({
@@ -294,11 +313,10 @@ function createDockerExecutors(
313
314 const durationMs = Date.now() - startTime;
315
297 - // Track as a standalone phase (not pre/fixture)
316 context.phases.push({
317 phase: 'fixture',
318 phaseIndex: context.phases.length + 1,
301 - totalPhases: context.phases.length + 1, // Updated later if more phases
319 + totalPhases: context.phases.length + 1,
320 command,
321 containerName,
322 durationMs,
@@ -322,26 +340,18 @@ function createDockerExecutors(
340 async function runFixture(options: RunFixtureOptions): Promise<E2ETestResult | E2ETestResultWithSetup> {
341 const { filename, setup } = options;
342
325 - // Smart mode: no setup (or empty string) = no volumes, just run directly
343 if (!setup) {
344 return runCmd(`node ${filename}`);
345 }
346
330 - // With setup: use Docker volumes
347 const volumeName = generateVolumeName(suiteName, nodeVersion);
332 - const containerBaseName = `e2e-${suiteName}-${nodeVersion.replace(/\./g, '-')}-${Date.now()}`;
333 -
334 - // The volume mounts at node_modules relative to the effective cwd
348 + const containerBaseName = `e2e-${suiteName}-node-${nodeVersion.replace(/\./g, '-')}-${Date.now()}`;
349 const volumeTarget = `${effectiveCwd.startsWith('/') ? effectiveCwd : `/app/${effectiveCwd}`}/node_modules`;
350
351 try {
338 - // 1. Create volume
352 await createVolume(volumeName);
340 -
341 - // 2. Initialize volume with correct ownership for node user (UID 1000)
353 await initializeVolumeOwnership(volumeName, imageTag);
354
344 - // 3. Run setup command with volume mounted read-write
355 const setupContainerName = `${containerBaseName}-setup`;
356 const setupStartTime = Date.now();
357 const setupResult = await runNodeContainer({
@@ -350,15 +360,10 @@ function createDockerExecutors(
360 cwd: effectiveCwd,
361 env: containerEnv,
362 name: setupContainerName,
353 - volumes: [{
354 - volume: volumeName,
355 - target: volumeTarget,
356 - readonly: false,
357 - }],
363 + volumes: [{ volume: volumeName, target: volumeTarget, readonly: false }],
364 });
365 const setupDurationMs = Date.now() - setupStartTime;
366
361 - // Track setup phase
367 context.phases.push({
368 phase: 'setup',
369 phaseIndex: 1,
@@ -371,7 +376,6 @@ function createDockerExecutors(
376 stderr: setupResult.stderr,
377 });
378
374 - // 4. Run fixture with volume mounted read-only (runs regardless of setup exit code)
379 const fixtureContainerName = `${containerBaseName}-fixture`;
380 const fixtureStartTime = Date.now();
381 const fixtureResult = await runNodeContainer({
@@ -380,15 +384,10 @@ function createDockerExecutors(
384 cwd: effectiveCwd,
385 env: containerEnv,
386 name: fixtureContainerName,
383 - volumes: [{
384 - volume: volumeName,
385 - target: volumeTarget,
386 - readonly: true,
387 - }],
387 + volumes: [{ volume: volumeName, target: volumeTarget, readonly: true }],
388 });
389 const fixtureDurationMs = Date.now() - fixtureStartTime;
390
391 - // Track fixture phase
391 context.phases.push({
392 phase: 'fixture',
393 phaseIndex: 2,
@@ -401,29 +400,19 @@ function createDockerExecutors(
400 stderr: fixtureResult.stderr,
401 });
402
404 - // 5. Return combined result (top-level is fixture result)
405 - return {
406 - ...fixtureResult,
407 - setup: setupResult,
408 - };
403 + return { ...fixtureResult, setup: setupResult };
404 } finally {
410 - // 6. Always cleanup volume (best-effort, doesn't throw)
405 await removeVolume(volumeName);
406 }
407 }
408
415 - /**
416 - * Finalize this version's log output.
417 - * Call this after all test phases have completed.
418 - */
409 const finalizeVersionLog = async (): Promise<void> => {
410 const totalDurationMs = Date.now() - context.versionStartTime;
421 -
422 - // Determine overall status based on exit codes
411 const allPassed = context.phases.every(p => p.exitCode === 0);
412 const status: 'pass' | 'fail' = allPassed ? 'pass' : 'fail';
413
414 await logManager.writeVersionSection({
415 + runtime: 'node',
416 version: nodeVersion,
417 status,
418 imageTag: context.imageTag,
@@ -435,12 +424,209 @@ function createDockerExecutors(
424 return { runCmd, runFixture, finalizeVersionLog, context };
425 }
426
427 +// ============================================================================
428 +// Deno Docker Executors
429 +// ============================================================================
430 +
431 +/**
432 + * Creates Docker execution utilities for a specific Deno version.
433 + */
434 +function createDenoDockerExecutors(
435 + config: RunE2EInternalConfig,
436 + denoVersion: string,
437 + imageTag: string,
438 + repoRoot: string,
439 + logManager: DebugLogManager
440 +) {
441 + const { cwd, suiteName, env, usesFixtures } = config;
442 + const containerEnv = buildContainerEnv(env);
443 + const effectiveCwd = usesFixtures ? `${cwd}/fixtures` : cwd;
444 +
445 + const context: VersionExecutionContext = {
446 + phases: [],
447 + versionStartTime: Date.now(),
448 + imageTag,
449 + };
450 +
451 + const runCmd = async (command: string): Promise<E2ETestResult> => {
452 + const containerName = `e2e-${suiteName}-deno-${denoVersion.replace(/\./g, '-')}-${Date.now()}`;
453 + const startTime = Date.now();
454 +
455 + const result = await runDenoContainer({
456 + imageTag,
457 + cmd: command,
458 + cwd: effectiveCwd,
459 + env: containerEnv,
460 + name: containerName,
461 + });
462 +
463 + const durationMs = Date.now() - startTime;
464 +
465 + context.phases.push({
466 + phase: 'fixture',
467 + phaseIndex: context.phases.length + 1,
468 + totalPhases: context.phases.length + 1,
469 + command,
470 + containerName,
471 + durationMs,
472 + exitCode: result.exitCode,
473 + stdout: result.stdout,
474 + stderr: result.stderr,
475 + });
476 +
477 + return result;
478 + };
479 +
480 + function runFixture(options: { filename: string }): Promise<E2ETestResult>;
481 + function runFixture(options: { filename: string; setup: string }): Promise<E2ETestResultWithSetup>;
482 + async function runFixture(options: RunFixtureOptions): Promise<E2ETestResult | E2ETestResultWithSetup> {
483 + const { filename, setup } = options;
484 +
485 + // For Deno without setup, just run the file directly
486 + if (!setup) {
487 + return runCmd(filename);
488 + }
489 +
490 + // Deno with setup: use Docker volumes for caching
491 + const volumeName = generateVolumeName(suiteName, denoVersion);
492 + const containerBaseName = `e2e-${suiteName}-deno-${denoVersion.replace(/\./g, '-')}-${Date.now()}`;
493 + // Deno caches to DENO_DIR, but we also support node_modules for npm packages
494 + const volumeTarget = `${effectiveCwd.startsWith('/') ? effectiveCwd : `/app/${effectiveCwd}`}/node_modules`;
495 +
496 + try {
497 + await createVolume(volumeName);
498 + await initializeVolumeOwnership(volumeName, imageTag);
499 +
500 + const setupContainerName = `${containerBaseName}-setup`;
501 + const setupStartTime = Date.now();
502 + const setupResult = await runDenoContainer({
503 + imageTag,
504 + cmd: setup,
505 + cwd: effectiveCwd,
506 + env: containerEnv,
507 + name: setupContainerName,
508 + volumes: [{ volume: volumeName, target: volumeTarget, readonly: false }],
509 + });
510 + const setupDurationMs = Date.now() - setupStartTime;
511 +
512 + context.phases.push({
513 + phase: 'setup',
514 + phaseIndex: 1,
515 + totalPhases: 2,
516 + command: setup,
517 + containerName: setupContainerName,
518 + durationMs: setupDurationMs,
519 + exitCode: setupResult.exitCode,
520 + stdout: setupResult.stdout,
521 + stderr: setupResult.stderr,
522 + });
523 +
524 + const fixtureContainerName = `${containerBaseName}-fixture`;
525 + const fixtureStartTime = Date.now();
526 + const fixtureResult = await runDenoContainer({
527 + imageTag,
528 + cmd: filename,
529 + cwd: effectiveCwd,
530 + env: containerEnv,
531 + name: fixtureContainerName,
532 + volumes: [{ volume: volumeName, target: volumeTarget, readonly: true }],
533 + });
534 + const fixtureDurationMs = Date.now() - fixtureStartTime;
535 +
536 + context.phases.push({
537 + phase: 'fixture',
538 + phaseIndex: 2,
539 + totalPhases: 2,
540 + command: filename,
541 + containerName: fixtureContainerName,
542 + durationMs: fixtureDurationMs,
543 + exitCode: fixtureResult.exitCode,
544 + stdout: fixtureResult.stdout,
545 + stderr: fixtureResult.stderr,
546 + });
547 +
548 + return { ...fixtureResult, setup: setupResult };
549 + } finally {
550 + await removeVolume(volumeName);
551 + }
552 + }
553 +
554 + const finalizeVersionLog = async (): Promise<void> => {
555 + const totalDurationMs = Date.now() - context.versionStartTime;
556 + const allPassed = context.phases.every(p => p.exitCode === 0);
557 + const status: 'pass' | 'fail' = allPassed ? 'pass' : 'fail';
558 +
559 + await logManager.writeVersionSection({
560 + runtime: 'deno',
561 + version: denoVersion,
562 + status,
563 + imageTag: context.imageTag,
564 + phases: context.phases,
565 + totalDurationMs,
566 + });
567 + };
568 +
569 + return { runCmd, runFixture, finalizeVersionLog, context };
570 +}
571 +
572 +// ============================================================================
573 +// Version normalization and resolution
574 +// ============================================================================
575 +
576 +/**
577 + * Normalize config to support both old (nodeVersions) and new (versions) formats.
578 + */
579 +function normalizeVersionConfig(config: E2EConfig): RuntimeVersions {
580 + // New format takes precedence
581 + if (config.versions) {
582 + return config.versions;
583 + }
584 + // Legacy format
585 + if (config.nodeVersions) {
586 + return { node: config.nodeVersions };
587 + }
588 + // Default: use current Node.js version
589 + return { node: ['current'] };
590 +}
591 +
592 +/**
593 + * Render a Node.js version meta for display in test names.
594 + */
595 +function renderNodeVersionMeta({ kind, value }: NodeVersionMeta): string {
596 + switch (kind) {
597 + case 'current':
598 + return `Node.js ${value} [current]`;
599 + case 'overridden':
600 + return `Node.js ${value} [overridden]`;
601 + case 'static':
602 + return `Node.js ${value}`;
603 + }
604 +}
605 +
606 +/**
607 + * Render a Deno version meta for display in test names.
608 + */
609 +function renderDenoVersionMeta({ kind, value }: DenoVersionMeta): string {
610 + switch (kind) {
611 + case 'current':
612 + return `Deno ${value} [current]`;
613 + case 'overridden':
614 + return `Deno ${value} [overridden]`;
615 + case 'static':
616 + return `Deno ${value}`;
617 + }
618 +}
619 +
620 +// ============================================================================
621 +// Main test runner
622 +// ============================================================================
623 +
624 /**
625 * Runs e2e tests using bun:test.
440 - * Creates a describe block per Node version and passes test utilities to defineTests.
626 + * Creates a describe block per runtime version and passes test utilities to defineTests.
627 *
442 - * In CI mode, versions not matching COMPOSIO_E2E_NODE_VERSION are skipped.
443 - * Each version's skipInCI state is computed by resolveNodeVersionMetaList().
628 + * Supports both Node.js and Deno runtimes.
629 + * In CI mode, versions not matching their respective env vars are skipped.
630 */
631 export function runE2E(config: RunE2EInternalConfig): void {
632 const { cwd, suiteName, defineTests, env } = config;
@@ -448,30 +634,28 @@ export function runE2E(config: RunE2EInternalConfig): void {
634 // Validate env vars early, before any Docker operations
635 validateRequiredEnvVars(env, suiteName);
636
451 - const nodeVersionMetaList = resolveNodeVersionMetaList(config.nodeVersions);
637 + const versions = normalizeVersionConfig(config);
638 const repoRoot = getRepoRoot();
639
640 + // Resolve versions for each runtime
641 + const nodeVersionMetaList = versions.node ? resolveNodeVersionMetaList(versions.node) : [];
642 + const denoVersionMetaList = versions.deno ? resolveDenoVersionMetaList(versions.deno) : [];
643 +
644 + // Build runtime version labels for logging
645 + const allRuntimeVersions = [
646 + ...nodeVersionMetaList.map(v => `Node.js ${v.value}`),
647 + ...denoVersionMetaList.map(v => `Deno ${v.value}`),
648 + ];
649 +
650 // Create the debug log manager for structured output
651 const logPath = resolve(repoRoot, cwd, 'DEBUG.log');
456 - const allVersions = nodeVersionMetaList.map(v => v.value);
652 const logManager = new DebugLogManager({
653 logPath,
654 suiteName,
655 testFilePath: `${cwd}/e2e.test.ts`,
461 - nodeVersions: allVersions,
656 + runtimeVersions: allRuntimeVersions,
657 });
658
464 - function renderNodeVersionMeta({ kind, value }: NodeVersionMeta) {
465 - switch (kind) {
466 - case 'current':
467 - return `Node.js ${value} [current]`;
468 - case 'overridden':
469 - return `Node.js ${value} [overridden]`;
470 - case 'static':
471 - return `Node.js ${value}`;
472 - }
473 - }
474 -
659 // Wrap all tests in a top-level describe to handle initialization and summary
660 describe(suiteName, () => {
661 // Initialize log file before any tests run
@@ -479,6 +663,7 @@ export function runE2E(config: RunE2EInternalConfig): void {
663 await logManager.initialize();
664 });
665
666 + // =========== Node.js Tests ===========
667 for (const nodeVersionMeta of nodeVersionMetaList) {
668 const testName = renderNodeVersionMeta(nodeVersionMeta);
669
@@ -486,8 +671,8 @@ export function runE2E(config: RunE2EInternalConfig): void {
671 if (nodeVersionMeta.skip.value) {
672 describe(`${testName} - skipped: ${nodeVersionMeta.skip.reason}`, () => {
673 beforeAll(async () => {
489 - // Write skip marker to log
674 await logManager.writeVersionSection({
675 + runtime: 'node',
676 version: nodeVersionMeta.value,
677 status: 'skipped',
678 reason: nodeVersionMeta.skip.reason || 'Skipped in CI',
@@ -501,21 +686,63 @@ export function runE2E(config: RunE2EInternalConfig): void {
686 }
687
688 describe(testName, () => {
504 - let executors: ReturnType<typeof createDockerExecutors>;
689 + let executors: ReturnType<typeof createNodeDockerExecutors>;
690
506 - // Ensure Docker image exists before tests run
691 beforeAll(async () => {
692 const imageTag = await ensureNodeImage(nodeVersionMeta.value, { repoRoot });
509 - executors = createDockerExecutors(config, nodeVersionMeta.value, imageTag, repoRoot, logManager);
510 - }, 600_000); // 10 minute timeout for Docker image build
693 + executors = createNodeDockerExecutors(config, nodeVersionMeta.value, imageTag, repoRoot, logManager);
694 + }, 600_000);
695 +
696 + defineTests({
697 + runtime: 'node',
698 + runCmd: (cmd) => executors.runCmd(cmd),
699 + runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
700 + });
701 +
702 + afterAll(async () => {
703 + if (executors) {
704 + await executors.finalizeVersionLog();
705 + }
706 + });
707 + });
708 + }
709 +
710 + // =========== Deno Tests ===========
711 + for (const denoVersionMeta of denoVersionMetaList) {
712 + const testName = renderDenoVersionMeta(denoVersionMeta);
713 +
714 + // Skip this version in CI if not selected
715 + if (denoVersionMeta.skip.value) {
716 + describe(`${testName} - skipped: ${denoVersionMeta.skip.reason}`, () => {
717 + beforeAll(async () => {
718 + await logManager.writeVersionSection({
719 + runtime: 'deno',
720 + version: denoVersionMeta.value,
721 + status: 'skipped',
722 + reason: denoVersionMeta.skip.reason || 'Skipped in CI',
723 + phases: [],
724 + });
725 + });
726 +
727 + it('this version should not run in this CI matrix job', () => {});
728 + });
729 + continue;
730 + }
731 +
732 + describe(testName, () => {
733 + let executors: ReturnType<typeof createDenoDockerExecutors>;
734 +
735 + beforeAll(async () => {
736 + const imageTag = await ensureDenoImage(denoVersionMeta.value, { repoRoot });
737 + executors = createDenoDockerExecutors(config, denoVersionMeta.value, imageTag, repoRoot, logManager);
738 + }, 600_000);
739
512 - // Call user's defineTests with bun:test functions and Docker utilities
740 defineTests({
741 + runtime: 'deno',
742 runCmd: (cmd) => executors.runCmd(cmd),
743 runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
744 });
745
518 - // Write version section after all tests for this version complete
746 afterAll(async () => {
747 if (executors) {
748 await executors.finalizeVersionLog();
ts/e2e-tests/_utils/src/types.ts
+46 -1
@@ -1,4 +1,4 @@
1 -import { WELL_KNOWN_NODE_VERSIONS } from './const';
1 +import { WELL_KNOWN_NODE_VERSIONS, WELL_KNOWN_DENO_VERSIONS } from './const';
2
3 export type NonEmptyArray<T> = [T, ...T[]];
4
@@ -14,6 +14,7 @@ export type NonEmptyArray<T> = [T, ...T[]];
14 export type NonEmptyString<T extends string> = T extends '' ? never : T;
15
16 export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];
17 +export type DenoVersionFromUser = typeof WELL_KNOWN_DENO_VERSIONS[number];
18
19 /**
20 * Result of CI skip check for a specific Node version.
@@ -32,6 +33,26 @@ export type NodeVersionMeta =
33 | { kind: 'overridden'; value: string; skip: SkipInCI }
34 | { kind: 'current'; value: string; skip: SkipInCI };
35
36 +/**
37 + * Metadata for a resolved Deno version to test against.
38 + * Includes skip state for CI mode.
39 + */
40 +export type DenoVersionMeta =
41 + | { kind: 'static'; value: Exclude<typeof WELL_KNOWN_DENO_VERSIONS[number], 'current'>; skip: SkipInCI }
42 + | { kind: 'overridden'; value: string; skip: SkipInCI }
43 + | { kind: 'current'; value: string; skip: SkipInCI };
44 +
45 +/**
46 + * Runtime versions to test against.
47 + * Supports both Node.js and Deno runtimes.
48 + */
49 +export interface RuntimeVersions {
50 + /** Node.js versions to test */
51 + node?: readonly NodeVersionFromUser[];
52 + /** Deno versions to test */
53 + deno?: readonly DenoVersionFromUser[];
54 +}
55 +
56 /**
57 * Result of executing a command in a Docker container.
58 */
@@ -63,10 +84,17 @@ export interface RunFixtureOptions {
84 setup?: string;
85 }
86
87 +/**
88 + * Supported runtime environments for e2e tests.
89 + */
90 +export type RuntimeKind = 'node' | 'deno';
91 +
92 /**
93 * Context passed to defineTests callback.
94 */
95 export interface DefineTestsContext {
96 + /** The runtime environment for this test execution */
97 + runtime: RuntimeKind;
98 /** Run an arbitrary command in the Docker container */
99 runCmd: (command: string) => Promise<E2ETestResult>;
100 /**
@@ -109,9 +137,26 @@ export interface E2EConfig {
137 * Node.js versions to test against.
138 * Each version creates a separate describe block.
139 * If not provided, defaults to the current Node runtime version.
140 + *
141 + * @deprecated Use `versions.node` instead. This property will be removed in a future version.
142 */
143 nodeVersions?: readonly NodeVersionFromUser[];
144
145 + /**
146 + * Runtime versions to test against.
147 + * Supports Node.js and Deno runtimes.
148 + * Takes precedence over the deprecated `nodeVersions` property.
149 + *
150 + * @example
151 + * ```typescript
152 + * versions: {
153 + * node: ['20.19.0', '22.12.0'],
154 + * deno: ['2.6.7'],
155 + * }
156 + * ```
157 + */
158 + versions?: RuntimeVersions;
159 +
160 /**
161 * Environment variables to pass to the Docker container.
162 */
ts/e2e-tests/runtimes/deno/esm-basic/README.md new
+47
@@ -0,0 +1,47 @@
1 +# Deno ESM Compatibility Test
2 +
3 +Verifies that `@composio/core` works correctly when imported via `npm:` specifier in Deno.
4 +
5 +## Why This Exists
6 +
7 +Deno v2.0+ supports npm packages via the `npm:` specifier. This suite ensures:
8 +
9 +- `import('npm:@composio/core')` resolves without errors
10 +- Named imports work
11 +- All public exports are accessible
12 +- No Node.js-only patterns break Deno consumers
13 +
14 +## What It Tests
15 +
16 +| Test | Description |
17 +| --------------------- | ------------------------------------------------ |
18 +| Dynamic import | `import('npm:@composio/core')` doesn't throw |
19 +| Composio class | Main class is exported and constructible |
20 +| OpenAIProvider | Provider class exports and instantiation |
21 +| AuthScheme | Auth enum is accessible |
22 +| ComposioError | Error classes are exported |
23 +| jsonSchemaToZodSchema | Utility function is exported |
24 +| constants | Constants namespace is accessible |
25 +| logger | Logger instance is exported |
26 +
27 +## Fixture
28 +
29 +```
30 +fixtures/
31 +├── deno.jsonc # Deno config to use local workspace packages
32 +└── test.ts # Deno test script using npm: specifier
33 +```
34 +
35 +The fixture uses Deno's native `npm:` specifier to import `@composio/core` and validates each export.
36 +
37 +The `deno.jsonc` file configures `nodeModulesDir: "auto"`, which tells Deno to resolve `npm:` imports from the local `node_modules` directory (populated by pnpm with symlinks to workspace packages). This ensures we test the local build of `@composio/core` rather than the published npm version.
38 +
39 +## Isolation Tool
40 +
41 +**Docker** with Deno version: 2.6.7
42 +
43 +## Running
44 +
45 +```bash
46 +pnpm test:e2e:deno
47 +```
ts/e2e-tests/runtimes/deno/esm-basic/e2e.test.ts new
+68
@@ -0,0 +1,68 @@
1 +/**
2 + * ESM compatibility e2e test for Deno
3 + *
4 + * Verifies that @composio/core can be imported using npm: specifier in Deno.
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 + versions: {
12 + deno: ['2.6.7'],
13 + },
14 + usesFixtures: true,
15 + defineTests: ({ runFixture }) => {
16 + let result: E2ETestResult;
17 +
18 + beforeAll(async () => {
19 + result = await runFixture({ filename: 'test.ts' });
20 + });
21 +
22 + describe('ESM compatibility (Deno)', () => {
23 + it('exits successfully', () => {
24 + expect(result.exitCode).toBe(0);
25 + });
26 +
27 + it('import npm:@composio/core succeeds', () => {
28 + expect(result.stdout).toContain('Test 1 passed: import() succeeded');
29 + });
30 +
31 + it('exports Composio class', () => {
32 + expect(result.stdout).toContain('Test 2 passed: Composio class is exported');
33 + });
34 +
35 + it('exports OpenAIProvider class', () => {
36 + expect(result.stdout).toContain('Test 3 passed: OpenAIProvider class is exported');
37 + });
38 +
39 + it('instantiates OpenAIProvider successfully', () => {
40 + expect(result.stdout).toContain('Test 4 passed: OpenAIProvider instantiated successfully');
41 + });
42 +
43 + it('exports AuthScheme', () => {
44 + expect(result.stdout).toContain('Test 5 passed: AuthScheme is exported');
45 + });
46 +
47 + it('exports Error classes', () => {
48 + expect(result.stdout).toContain('Test 6 passed: Error classes are exported');
49 + });
50 +
51 + it('exports jsonSchemaToZodSchema', () => {
52 + expect(result.stdout).toContain('Test 7 passed: jsonSchemaToZodSchema is exported');
53 + });
54 +
55 + it('exports constants namespace', () => {
56 + expect(result.stdout).toContain('Test 8 passed: constants namespace is exported');
57 + });
58 +
59 + it('exports logger', () => {
60 + expect(result.stdout).toContain('Test 9 passed: logger is exported');
61 + });
62 +
63 + it('completes all tests', () => {
64 + expect(result.stdout).toContain('All ESM compatibility tests passed!');
65 + });
66 + });
67 + },
68 +});
ts/e2e-tests/runtimes/deno/esm-basic/fixtures/deno.jsonc new
+6
@@ -0,0 +1,6 @@
1 +{
2 + "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json",
3 + // Use the existing node_modules from pnpm workspace
4 + // This resolves npm:@composio/core to the local workspace package
5 + "nodeModulesDir": "auto"
6 +}
ts/e2e-tests/runtimes/deno/esm-basic/fixtures/test.ts new
+76
@@ -0,0 +1,76 @@
1 +/**
2 + * ESM compatibility test for @composio/core in Deno
3 + * Uses npm: specifier to import the package
4 + */
5 +
6 +import { assert } from 'jsr:@std/assert@^1.0.0';
7 +
8 +console.log('Testing ESM compatibility for @composio/core in Deno...\n');
9 +
10 +// Test 1: Dynamic import works via npm: specifier
11 +console.log('Test 1: import("npm:@composio/core") should not throw...');
12 +let composioModule: Record<string, unknown>;
13 +try {
14 + composioModule = await import('npm:@composio/core');
15 + console.log('Test 1 passed: import() succeeded\n');
16 +} catch (error) {
17 + console.error('Test 1 failed: import() threw an error');
18 + console.error(error);
19 + Deno.exit(1);
20 +}
21 +
22 +// Test 2: Composio class is exported
23 +console.log('Test 2: Composio class should be exported...');
24 +assert(composioModule.Composio, 'Composio class should be exported');
25 +assert(typeof composioModule.Composio === 'function', 'Composio should be a constructor');
26 +console.log('Test 2 passed: Composio class is exported\n');
27 +
28 +// Test 3: OpenAIProvider class is exported
29 +console.log('Test 3: OpenAIProvider class should be exported...');
30 +assert(composioModule.OpenAIProvider, 'OpenAIProvider class should be exported');
31 +assert(typeof composioModule.OpenAIProvider === 'function', 'OpenAIProvider should be a constructor');
32 +console.log('Test 3 passed: OpenAIProvider class is exported\n');
33 +
34 +// Test 4: Can instantiate OpenAIProvider
35 +console.log('Test 4: OpenAIProvider should be instantiable...');
36 +try {
37 + const OpenAIProvider = composioModule.OpenAIProvider as new () => unknown;
38 + const provider = new OpenAIProvider();
39 + assert(provider, 'Provider instance should exist');
40 + console.log('Test 4 passed: OpenAIProvider instantiated successfully\n');
41 +} catch (error) {
42 + console.error('Test 4 failed: Could not instantiate OpenAIProvider');
43 + console.error(error);
44 + Deno.exit(1);
45 +}
46 +
47 +// Test 5: AuthScheme is exported
48 +console.log('Test 5: AuthScheme should be exported...');
49 +assert(composioModule.AuthScheme, 'AuthScheme should be exported');
50 +console.log('Test 5 passed: AuthScheme is exported\n');
51 +
52 +// Test 6: Error classes are exported
53 +console.log('Test 6: Error classes should be exported...');
54 +assert(composioModule.ComposioError, 'ComposioError should be exported');
55 +console.log('Test 6 passed: Error classes are exported\n');
56 +
57 +// Test 7: jsonSchemaToZodSchema utility is exported
58 +console.log('Test 7: jsonSchemaToZodSchema should be exported...');
59 +assert(composioModule.jsonSchemaToZodSchema, 'jsonSchemaToZodSchema should be exported');
60 +assert(typeof composioModule.jsonSchemaToZodSchema === 'function', 'jsonSchemaToZodSchema should be a function');
61 +console.log('Test 7 passed: jsonSchemaToZodSchema is exported\n');
62 +
63 +// Test 8: constants namespace is exported
64 +console.log('Test 8: constants namespace should be exported...');
65 +assert(composioModule.constants, 'constants should be exported');
66 +console.log('Test 8 passed: constants namespace is exported\n');
67 +
68 +// Test 9: logger is exported
69 +console.log('Test 9: logger should be exported...');
70 +assert(composioModule.logger, 'logger should be exported');
71 +console.log('Test 9 passed: logger is exported\n');
72 +
73 +console.log('========================================');
74 +console.log('All ESM compatibility tests passed!');
75 +console.log('========================================');
76 +Deno.exit(0);
ts/e2e-tests/runtimes/deno/esm-basic/package.json new
+15
@@ -0,0 +1,15 @@
1 +{
2 + "name": "@e2e-tests/deno-esm-basic",
3 + "version": "0.0.0",
4 + "private": true,
5 + "type": "module",
6 + "scripts": {
7 + "typecheck": "tsc --noEmit",
8 + "test:e2e": "bun test e2e.test.ts",
9 + "test:e2e:deno": "bun test e2e.test.ts"
10 + },
11 + "devDependencies": {
12 + "@composio/core": "workspace:*",
13 + "@e2e-tests/utils": "workspace:*"
14 + }
15 +}
ts/e2e-tests/runtimes/deno/esm-basic/tsconfig.json new
+12
@@ -0,0 +1,12 @@
1 +{
2 + "$schema": "https://json.schemastore.org/tsconfig",
3 + "compilerOptions": {
4 + "target": "es2022",
5 + "module": "esnext",
6 + "moduleResolution": "bundler",
7 + "strict": true,
8 + "skipLibCheck": true,
9 + "noEmit": true
10 + },
11 + "include": ["e2e.test.ts"]
12 +}
turbo.jsonc
+5
@@ -27,6 +27,11 @@
27 "env": ["COMPOSIO_API_KEY", "COMPOSIO_E2E_NODE_VERSION", "OPENAI_API_KEY"],
28 "cache": false
29 },
30 + "test:e2e:deno": {
31 + "dependsOn": ["^build"],
32 + "env": ["COMPOSIO_API_KEY", "COMPOSIO_E2E_DENO_VERSION", "OPENAI_API_KEY"],
33 + "cache": false
34 + },
35 "test:e2e:cloudflare": {
36 "dependsOn": ["^build"],
37 "env": ["COMPOSIO_API_KEY", "OPENAI_API_KEY"],