Skip to content

test: use ESM test files#66

Merged
chenjiahan merged 1 commit into
mainfrom
chore/use-esm-test-files
Jun 29, 2026
Merged

test: use ESM test files#66
chenjiahan merged 1 commit into
mainfrom
chore/use-esm-test-files

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

This PR updates the Playwright tests to run with standard ESM semantics instead of relying on a test/package.json CommonJS scope. The tests now use import.meta.dirname for fixture paths and createRequire(import.meta.url) only where they need to verify the CommonJS UMD output, so Rsbuild config files are loaded under the repository's normal module scope.

Related Links

#63

@chenjiahan chenjiahan merged commit 44fbd38 into main Jun 29, 2026
6 checks passed
@chenjiahan chenjiahan deleted the chore/use-esm-test-files branch June 29, 2026 04:01
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 41daf544-201f-4e18-8529-da9a375f9132

📥 Commits

Reviewing files that changed from the base of the PR and between 19f3691 and 357134b.

📒 Files selected for processing (6)
  • test/basic/index.test.ts
  • test/environments/index.test.ts
  • test/export-array/index.test.ts
  • test/export/index.test.ts
  • test/package.json
  • test/split-chunks/index.test.ts
💤 Files with no reviewable changes (1)
  • test/package.json

📝 Walkthrough

Walkthrough

test/package.json drops the "type": "commonjs" declaration, allowing the test package to be treated as ESM. All five test files (basic, environments, export-array, export, split-chunks) replace __dirname with import.meta.dirname for Rsbuild cwd, loadConfig, writeFileSync, and filesystem assertion paths. Where require() is needed to load built CommonJS output, each test now creates a local require function via createRequire(import.meta.url).

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: switching test files to ESM semantics.
Description check ✅ Passed The description accurately describes the ESM test changes and why createRequire is still needed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/use-esm-test-files

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 357134b28f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread test/package.json
@@ -1,3 +0,0 @@
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve native ESM config coverage

With this package scope removed, the fixture rsbuild.config.ts files are now loaded under the root "type": "module", but they still import the built package via the relative directory specifier ../../dist (for example, test/basic/rsbuild.config.ts). Native Node ESM rejects relative directory imports, so loadConfig()'s default auto loader falls back to jiti instead of exercising the standard ESM semantics this change is meant to test; update the fixture imports to the explicit built entry (for example ../../dist/index.js) or force the native loader so regressions in native ESM loading are actually caught.

Useful? React with 👍 / 👎.

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.

1 participant