Skip to content

Fix server Jest test structure and standardize test scripts#5909

Merged
yau-wd merged 2 commits intomainfrom
fix/server-jest-structure
Mar 5, 2026
Merged

Fix server Jest test structure and standardize test scripts#5909
yau-wd merged 2 commits intomainfrom
fix/server-jest-structure

Conversation

@yau-wd
Copy link
Contributor

@yau-wd yau-wd commented Mar 5, 2026

This PR fixes Jest test discovery issues in the server package.

pnpm install && pnpm lint-fix && pnpm build-force && pnpm test

Before After
image image

pnpm install && pnpm lint-fix && pnpm build-force && pnpm test:coverage

Before After
image image

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the server package's Jest testing setup to resolve test discovery issues. It standardizes the test execution commands in package.json by simplifying the default test script and introducing dedicated scripts for watching tests and generating coverage reports. Furthermore, the test file structure has been streamlined to leverage Jest's automatic test discovery, removing the previous manual aggregation of tests and enhancing overall test maintainability.

Highlights

  • Standardized Jest Scripts: The package.json now includes a simplified test command and new test:watch and test:coverage scripts for more granular test execution and management.
  • Streamlined Test Discovery: Test files have been refactored to allow Jest to automatically discover and run tests, eliminating the need for a central index.test.ts file that manually imported and executed test suites.
  • Removed Redundant Test Files: Specific route test files (organization-user.route.test.ts, user.route.test.ts) and the main index.test.ts were removed as part of the test structure overhaul, simplifying the test directory.
Changelog
  • packages/server/package.json
    • Updated the test script to a simpler jest command
    • Added test:watch script for running Jest in watch mode
    • Added test:coverage script for generating test coverage reports
  • packages/server/test/index.test.ts
    • Removed the central test entry file that manually imported and ran other test suites
  • packages/server/test/routes/v1/organization-user.route.test.ts
    • Removed the dedicated test file for organization user routes
  • packages/server/test/routes/v1/user.route.test.ts
    • Removed the dedicated test file for user routes
  • packages/server/test/utils/api-key.util.test.ts
    • Refactored the test file by removing the apiKeyTest function wrapper, allowing Jest to discover tests directly
  • packages/server/test/utils/sanitizeFlowData.test.ts
    • Refactored the test file by removing the sanitizeFlowDataTest function wrapper, enabling direct Jest test discovery
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 introduces significant improvements to the test infrastructure for the server package. The core change involves refactoring the test structure to allow Jest to auto-discover and run test files individually, which is a more standard and scalable approach. This was achieved by removing the single, monolithic test entry point (test/index.test.ts) that contained problematic practices like a long, hardcoded wait time. The test scripts in package.json have been standardized, removing flags that can mask issues (like --forceExit) and adding common scripts for watch mode and coverage. The existing test files have been updated to be standalone, completing the transition to a modern Jest setup. These changes effectively resolve the test discovery issues and create a more robust and efficient testing environment.

@yau-wd yau-wd requested a review from HenryHengZJ March 5, 2026 08:58
@yau-wd yau-wd merged commit 84758d7 into main Mar 5, 2026
7 checks passed
@yau-wd yau-wd deleted the fix/server-jest-structure branch March 5, 2026 10:18
- run: pnpm build
env:
NODE_OPTIONS: '--max_old_space_size=4096'
- run: pnpm test:coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

are we still running integration test for server? if it's unit test we shouldn't need to depend on build

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.

3 participants