Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Storybook test-runner fails with "Must use import to load ES Module" because it uses require() to load the config, but project has "type": "module" in package.json.

Changes

  • Renamed .storybook/test-runner.ts.storybook/test-runner.cjs
  • Converted to CommonJS syntax: module.exports instead of export default
  • Replaced TypeScript type imports with JSDoc annotations
// Before (test-runner.ts)
import type { TestRunnerConfig } from '@storybook/test-runner';
export default config;

// After (test-runner.cjs)
/** @type {import('@storybook/test-runner').TestRunnerConfig} */
module.exports = { ... };

The .cjs extension explicitly marks the file as CommonJS, allowing Jest to load it with require() regardless of project module type.

Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21488240044/job/61935699163#step:7:1


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

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Jan 29, 2026 11:36pm
objectui-components Ready Ready Preview, Comment Jan 29, 2026 11:36pm
objectui-crm-app Error Error Jan 29, 2026 11:36pm

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix broken CSS styles in user interface Fix Storybook test-runner config loading in ES module project Jan 29, 2026
Copilot AI requested a review from hotlong January 29, 2026 23:31
@hotlong hotlong marked this pull request as ready for review January 29, 2026 23:59
Copilot AI review requested due to automatic review settings January 29, 2026 23:59
@hotlong hotlong merged commit db72d19 into copilot/upgrade-objectstack-spec-v061 Jan 29, 2026
6 of 7 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Storybook test-runner failing to load its configuration in an ES module ("type": "module") project by moving the config to an explicit CommonJS module.

Changes:

  • Renamed the Storybook test-runner config from .storybook/test-runner.ts to .storybook/test-runner.cjs.
  • Switched export style from export default to module.exports.
  • Replaced TypeScript-only typing with a JSDoc @type annotation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
.storybook/test-runner.ts Removed the TypeScript/ESM-exported test-runner config that Jest/test-runner attempted to load via require().
.storybook/test-runner.cjs Added a CommonJS-exported test-runner config with JSDoc typing to allow require() loading in an ESM project.

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