Skip to content

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

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

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

Conversation

@GautamSharda
Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

For googleapis/librarian#4583

@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

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