Skip to content

chore: move .mocharc.js to root and delete library copies#8069

Open
GautamSharda wants to merge 5 commits intomainfrom
move-mocharc-to-root
Open

chore: move .mocharc.js to root and delete library copies#8069
GautamSharda wants to merge 5 commits intomainfrom
move-mocharc-to-root

Conversation

@GautamSharda
Copy link
Copy Markdown
Contributor

@GautamSharda GautamSharda commented Apr 16, 2026

This PR centralizes the Mocha configuration across the monorepo for googleapis/librarian#4583.

It does so by creating a unified .mocharc.cjs file at the repository root with common settings and deleting all library-level .mocharc.js and .mocharc.json files within the packages/ directory.

I verified the changes by running tests in a representative package (packages/google-cloud-aiplatform) using the internal CI script (ci/run_single_test.sh). The tests passed successfully, confirming that the root-level configuration was correctly picked up. Also, the full suite of CI checks (Kokoro system tests) ran on this PR and all checks have passed successfully.

@GautamSharda GautamSharda requested a review from a team as a code owner April 16, 2026 23:16
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request centralizes Mocha configuration by removing local .mocharc files across the monorepo and updating the root configuration. Feedback highlights that switching to ESM exports in the root .mocharc.js could cause runtime errors in CommonJS environments. Furthermore, the reviewer pointed out that the omission of the recursive flag in the centralized config might lead to silent test skips, as several deleted local configurations previously relied on it for test discovery.

Comment thread .mocharc.js Outdated
config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`;
}
module.exports = config
export default config
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.

high

Changing the export to export default in a .js file will cause a SyntaxError at runtime if the root package.json does not contain "type": "module". Since this configuration is being centralized to replace local versions that were using CommonJS (module.exports), it is safer to maintain CommonJS compatibility to ensure it works across all packages in the monorepo.

Additionally, please ensure that the config object (defined in the lines above) includes "recursive": true. Several of the deleted local configurations (e.g., in gapic-node-processing, grafeas, and google-cloud-monitoring) specifically enabled this flag. If it is missing from this centralized root configuration, Mocha will fail to discover tests in subdirectories for those packages, leading to silent test skips in CI.

Suggested change
export default config
module.exports = config

@quirogas quirogas self-requested a review April 20, 2026 19:57
Copy link
Copy Markdown
Contributor

@quirogas quirogas left a comment

Choose a reason for hiding this comment

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

LGTM, please add a PR description before merging the PR.

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