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

NoMongo: adding a CreateMockContext Factory function for unit testing #3292

Open
Piyushk8 opened this issue Feb 24, 2025 · 2 comments
Open
Assignees
Labels
feature request no-issue-activity No issue activity refactor Refactor the code to improve its quality test Testing application unapproved Unapproved for Pull Request

Comments

@Piyushk8
Copy link

Is your feature request related to a problem? Please describe.
Current unit tests have multiple individually defined mock GraphQL contexts, which leads to inconsistencies, duplicated code, and increased maintenance overhead.

Describe the solution you'd like
Develop a centralized createMockContext factory function to generate consistent mock contexts. This factory will streamline test setups and provide a unified method to override defaults when needed.

Describe alternatives you've considered

  • Utilizing a shared single mock object, which can be shared across all unit test files and make changes in it as per requirements

Approach to be followed (optional)

  1. Create a new file mockContextFactory.ts containing the createMockContext function.
  2. Implement an override mechanism that accepts custom parameters to modify the default context.
  3. Refactor existing tests to use the new factory for consistency and improved maintainability.
  4. Add dedicated unit tests for the factory function to ensure its correctness and flexibility.

Additional context
Implementing this factory will enhance test reliability, reduce duplication, and improve overall code readability by centralizing mock context creation.

Potential internship candidates

Please read this if you are planning to apply for a Palisadoes Foundation internship

@Piyushk8
Copy link
Author

please assign.

@github-actions github-actions bot added refactor Refactor the code to improve its quality test Testing application unapproved Unapproved for Pull Request labels Feb 24, 2025
Copy link

github-actions bot commented Mar 4, 2025

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request no-issue-activity No issue activity refactor Refactor the code to improve its quality test Testing application unapproved Unapproved for Pull Request
Projects
Status: Backlog
Status: Backlog
Development

No branches or pull requests

1 participant