Back to Composio

Node.js ESM Compatibility Test

ts/e2e-tests/runtimes/node/esm-basic/README.md

0.11.11.7 KB
Original Source

Node.js ESM Compatibility Test

Verifies that @composio/core works correctly when imported via import in ES Module environments.

Why This Exists

ESM is the modern JavaScript module standard. This suite ensures:

  • import('@composio/core') resolves without errors
  • Named imports work (import { Composio } from '@composio/core')
  • All public exports are accessible
  • No CJS-only patterns break ESM consumers

What It Tests

TestDescription
Dynamic importimport('@composio/core') doesn't throw
Composio classMain class is exported and constructible
OpenAIProviderProvider class exports and instantiation
AuthSchemeAuth enum is accessible
ComposioErrorError classes are exported
jsonSchemaToZodSchemaUtility function is exported
constantsConstants namespace is accessible
loggerLogger instance is exported
Named importsDestructuring imports work correctly

Fixture

fixtures/
└── test.mjs    # ESM test script using import()

The fixture is a standalone .mjs file that:

  • Uses import('@composio/core') to dynamically import the package
  • Verifies each export exists and has the correct type
  • Tests destructured named imports ({ Composio, OpenAIProvider })
  • Attempts to instantiate OpenAIProvider to catch runtime errors
  • Outputs test results to stdout with pass/fail markers

Isolation Tool

Docker with Node.js versions: 20.18.0, 20.19.0, 22.12.0.

Running

bash
pnpm test:e2e