Skip to content

Add ESM and CJS test suites for distribution testing - #38

Draft
oyve with Copilot wants to merge 2 commits into
mainfrom
copilot/add-tests-for-commonjs-esm
Draft

Add ESM and CJS test suites for distribution testing#38
oyve with Copilot wants to merge 2 commits into
mainfrom
copilot/add-tests-for-commonjs-esm

Conversation

Copilot AI commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Description

Adds separate test suites that verify both CommonJS and ESM builds work correctly when imported by consumers. Tests the compiled dist/ output rather than TypeScript source.

Type of Change

  • New formula/feature (non-breaking change that adds functionality)
  • Test improvements

Related Issue

Fixes #(issue number)

Changes Made

  • Added tests-dist/esm/temperature.test.mjs - ESM tests importing from dist/esm/
  • Added tests-dist/cjs/temperature.test.cjs - CJS tests importing via require() from dist/cjs/
  • Added jest.config.esm.mjs and jest.config.cjs.cjs for separate test configurations
  • Added npm scripts: test:esm, test:cjs, test:dist, test:all

Formula Details (if applicable)

N/A - test infrastructure only

Testing

Test Coverage

  • Added tests for new functionality
  • All tests pass locally (npm test)
  • Build succeeds (npm run build)

Test Results

npm run test:all

# Source tests: 177 passed
# ESM dist tests: 13 passed  
# CJS dist tests: 13 passed

Manual Testing

Verified both import styles work:

// ESM (tests-dist/esm/temperature.test.mjs)
import * as temperature from '../../dist/esm/formulas/temperature.js';

// CJS (tests-dist/cjs/temperature.test.cjs)
const temperature = require('../../dist/cjs/formulas/temperature.cjs');

Documentation

  • Added/updated JSDoc comments

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Breaking Changes

  • This PR introduces breaking changes

Performance Impact

  • No performance impact

Dependencies

  • No new dependencies

Reviewer Notes

  • Key files to review: jest.config.esm.mjs, jest.config.cjs.cjs, package.json scripts
  • Areas needing special attention: ESM test uses --experimental-vm-modules flag for Jest
Original prompt

Is it possible to make two tests suits that test both CommonJS and ESM? As this library target both in it's compile. I.e. by implementing the same Temperature.ts function by importing it in each respective way for CommonJS and ESM. Or do we need a test environment for this?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 1, 2025
Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test suites for CommonJS and ESM compatibility Add ESM and CJS test suites for distribution testing Dec 1, 2025
Copilot AI requested a review from oyve December 1, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants