Skip to content

Migrate regenerator tests - #18020

Merged
JLHwung merged 9 commits into
babel:mainfrom
JLHwung:migrate-regenerator-tests
Jun 8, 2026
Merged

JLHwung merged 9 commits into
babel:mainfrom
JLHwung:migrate-regenerator-tests

Conversation

@JLHwung

@JLHwung JLHwung commented May 26, 2026

Copy link
Copy Markdown
Contributor
Q 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

In this PR we migrate the test runner of regenerator tests, previously imported from the upstream repo, from mocha to jest. This should simplify the build pipeline

It will also unblock #18015 since only mocha 10 depends on yargs@16 which is broken on Node.js 26. The v7 backport of this PR passes all the tests on my local machine.

@babel-bot

babel-bot commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61708

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Migrates the @babel/plugin-transform-regenerator upstream regenerator test suite from being executed via Mocha to being executed via Jest, aiming to simplify the test pipeline and improve CI/runtime performance.

Changes:

  • Replace Mocha-based fixture execution with a Jest-based runner invoked from test/regenerator.js.
  • Add a dedicated Jest config for regenerator fixtures and adjust fixture syntax to be Jest-compatible.
  • Remove the package-level Mocha dependency and update the lockfile accordingly.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Removes mocha and its transitive dependencies from the lockfile.
packages/babel-plugin-transform-regenerator/package.json Drops mocha from devDependencies for this workspace package.
packages/babel-plugin-transform-regenerator/test/regenerator.js Replaces Mocha spawning with a queued/single Jest invocation for regenerator fixture tests.
packages/babel-plugin-transform-regenerator/test/regenerator-fixtures/tests.transform.js Replaces Mocha-only context() usage with describe() for Jest compatibility.
packages/babel-plugin-transform-regenerator/test/regenerator-fixtures/jest.config.js Adds Jest configuration for running the regenerator fixture tests.

馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/babel-plugin-transform-regenerator/test/regenerator.js Outdated
Comment thread packages/babel-plugin-transform-regenerator/package.json
@JLHwung
JLHwung force-pushed the migrate-regenerator-tests branch from 2c111fa to 2b854fa Compare May 26, 2026 19:13
@pkg-pr-new

pkg-pr-new Bot commented May 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 79e95c4

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove the yargs resolution from the root package.json?

@JLHwung

JLHwung commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Can we remove the yargs resolution from the root package.json?

Frankly I don't know if it works although tests on my local machine pass. The yargs@16 and @17 are still in the lock file but maybe they are not invoked at all. Let's see if CI can be green.

@JLHwung

JLHwung commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Can we remove the yargs resolution from the root package.json?

Frankly I don't know if it works although tests on my local machine pass. The yargs@16 and @17 are still in the lock file but maybe they are not invoked at all. Let's see if CI can be green.

No, it doesn't work because c8 requires yargs@17, used in our coverage test. For the time being I will only override the c8/yargs resolution only.

const { require, __dirname } = commonJS(import.meta.url);

const mochaDir = dirname(require.resolve("mocha"));
const jestDir = dirname(require.resolve("jest/package.json"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use the run or runCLI functions in jest, but that's fine.

@JLHwung JLHwung May 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will runCLI run jest in a standalone process? The tests here unfortunately require per-test process isolation because of mutation of global states.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess so. It will probably initialize a new jest-light-runner.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to use runCLI.

@JLHwung
JLHwung force-pushed the migrate-regenerator-tests branch from 7512aa2 to 79e95c4 Compare June 1, 2026 13:09
@JLHwung
JLHwung merged commit 2688fbd into babel:main Jun 8, 2026
57 checks passed
@JLHwung
JLHwung deleted the migrate-regenerator-tests branch June 8, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants