Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Feat(pk: unit testing): Add workspace support for monorepos #865

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

HeavenlyEntity
Copy link

@HeavenlyEntity HeavenlyEntity commented Dec 20, 2024

Add Monorepo Support for Jest Configuration 🚀

Overview

This PR adds automatic workspace/monorepo detection to the SuiteCloud Jest configuration, making it easier to work with SuiteCloud projects in monorepo setups while maintaining backward compatibility for existing single-repo users.

Changes

  • Added automatic detection of common workspace configurations (pnpm, Yarn/npm workspaces, Lerna)
  • Implemented smart rootDir resolution that:
    • Automatically detects workspace root
    • Falls back to provided rootDir if specified
    • Maintains existing behavior if neither exists
  • Added test scoping to ensure tests only run in the current workspace package
  • Simplified customStubs initialization

Testing

The changes have been tested with:

  • Standard single-repo setups (backward compatibility)
  • pnpm workspaces
  • Yarn/npm workspaces
  • Lerna-based repositories

Usage

No changes required for existing users. For monorepo users, the configuration will automatically detect the workspace root and configure Jest appropriately.

Example

const config = build({
projectFolder: 'src',
projectType: ProjectType.SUITEAPP,
// rootDir is now optional in monorepos
customStubs: []
});

Notes

  • Workspace detection looks up to 5 directory levels to find workspace configuration
  • Test execution is scoped to the current package directory using Jest's roots configuration

Adds ability to configure Jest rootDir through options for monorepo setups while maintaining backward compatibility with existing single-repo configurations.
Clarified the usage of the rootDir option in the Jest configuration examples for both ACP and SUITEAPP project types, enhancing documentation for better understanding.
…ion in Jest

Expanded the documentation for the `rootDir` property in Jest configuration, providing clear examples for both standard project structures and monorepo setups. This update aims to improve user understanding and ease of configuration.
Added a method to automatically detect the workspace root for Jest configurations, enhancing support for monorepo setups. The customStubs property is now initialized with an empty array if not provided, and the rootDir is determined using the new detection method or falls back to the provided option. This improves flexibility and usability for users managing multiple projects.
…onorepo support

Revised the documentation for the `rootDir` property in Jest configuration, emphasizing its optional nature and improved automatic detection in monorepo setups. Added detailed examples for both standard and monorepo project structures, highlighting how Jest now scopes tests and resolves modules across workspaces without manual configuration. This update aims to enhance user understanding and streamline configuration processes.
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 20, 2024
@alisyed-19
Copy link
Member

Hi @HeavenlyEntity

Thank you for your contribution to the repository! We greatly appreciate the time and effort you’ve invested in this merge request.

Our team will review your submission promptly to ensure it aligns with our project goals and guidelines. We’ll keep you updated throughout the review process, and if we have any questions or suggestions, we’ll reach out to you here directly.

Thank you again for contributing and helping us improve the project!

@HeavenlyEntity
Copy link
Author

Of course! Let me know if you need any changes! 👉

@HeavenlyEntity HeavenlyEntity changed the title ✨ Feat: Add workspace support for monorepos ✨ Feat(testing): Add workspace support for monorepos Dec 26, 2024
@HeavenlyEntity HeavenlyEntity changed the title ✨ Feat(testing): Add workspace support for monorepos ✨ Feat(pk: unit testing): Add workspace support for monorepos Dec 26, 2024
Revised the README.md for the unit testing package to replace the link to CORE_STUBS with a new reference to the comprehensive stubs documentation. Additionally, introduced a new README.md file in the stubs directory, detailing all available SuiteScript 2.x stubs, their methods, and usage examples. This update enhances clarity and accessibility of information for users implementing unit tests with SuiteCloud.
…nd crypto operations

Updated unit testing stubs to improve test coverage and functionality. Refactored existing tests to perform actual record, search, and crypto operations instead of mocking. This includes implementing realistic scenarios for loading and saving records, executing search operations with mock results, and performing encryption with specified algorithms. These changes aim to provide more robust testing capabilities and better simulate real-world usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants