Skip to content

Fix server test coverage script#5843

Closed
yau-wd wants to merge 3 commits into
mainfrom
fix/server-test-coverage-script
Closed

Fix server test coverage script#5843
yau-wd wants to merge 3 commits into
mainfrom
fix/server-test-coverage-script

Conversation

@yau-wd
Copy link
Copy Markdown
Contributor

@yau-wd yau-wd commented Feb 25, 2026

pnpm test

Before After
image image

pnpm test:coverage

Before After
image image

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @yau-wd, 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 enhances the server's testing infrastructure by addressing compatibility issues with ESM-only modules in Jest and providing a dedicated command for generating test coverage reports. These changes streamline the testing process and improve the ability to monitor code coverage for the server package.

Highlights

  • Jest Configuration Update: Configured jest.config.js to include moduleNameMapper directives. This change stubs ESM-only @modelcontextprotocol/sdk imports, ensuring they are correctly handled within Jest's CommonJS runtime environment during server-side testing.
  • New Test Coverage Script: Added a new test:coverage script to packages/server/package.json. This script allows developers to run Jest specifically for generating test coverage reports, complementing the existing test script.
Changelog
  • packages/server/jest.config.js
    • Added moduleNameMapper configuration to correctly stub ESM-only SDK imports for Jest's CJS runtime.
  • packages/server/package.json
    • Introduced a new test:coverage script to run Jest with coverage reporting enabled.
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.

@yau-wd yau-wd added the bug Something isn't working label Feb 25, 2026
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 addresses an issue with the server test coverage script. It introduces a moduleNameMapper in the Jest configuration to handle ESM-only SDK imports and adds a test:coverage script to package.json. The changes are functional, but I've provided a couple of suggestions to improve maintainability and conciseness in both files.

Comment thread packages/server/jest.config.js Outdated
Comment thread packages/server/package.json Outdated
Comment thread turbo.json
"test": {},
"test:coverage": {},
"test": {
"dependsOn": ["^build"]
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.

do we really need to depend on build for unit tests? usually unit test shouldn't rely on build as the tests are only at unit level

Comment thread turbo.json
"dependsOn": ["^build"]
},
"test:coverage": {
"dependsOn": ["^build"]
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.

same comment about build dependency as test script

"cypress:ci": "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3000 cypress:run",
"test": "jest --runInBand --detectOpenHandles --forceExit"
"test": "jest --runInBand --detectOpenHandles --forceExit",
"test:coverage": "pnpm test --coverage"
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.

can you confirm if this work when running at project level? test seems to be halting at the end of test run the last time I tried

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I’m using supertest for integration testing, so the server has to fully initialize before tests run. On Windows starting up Flowise is very slow, which is why I added a 3-minute wait to avoid flaky failures. The tests aren’t truly stuck/halt, they’re waiting for startup to complete.

https://github.com/FlowiseAI/Flowise/blob/main/packages/server/test/index.test.ts

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.

maybe we should separate this out and use test:integration (or test:int, test:int:coverage for example) instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with splitting the test command.

For now, I’ll close this PR first since I’m still new to writing test scripts, and this test is only verifying a simple “Hello World”.

Also, we may not be using supertest in the future, so I’d prefer not to introduce new integration-test scripts until we decide on the longer-term testing approach.

@yau-wd yau-wd closed this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants