Skip to content

fix: resolve failing tests by improving JSDOM mock and mocking DOMPurify#12

Merged
allenhutchison merged 3 commits into
mainfrom
fix/jsdom-test-failures
Nov 14, 2025
Merged

fix: resolve failing tests by improving JSDOM mock and mocking DOMPurify#12
allenhutchison merged 3 commits into
mainfrom
fix/jsdom-test-failures

Conversation

@allenhutchison
Copy link
Copy Markdown
Contributor

This PR fixes the failing tests in workspace-mcp-server.\n\nChanges:\n- Improved JSDOM mock in src/__tests__/mocks/jsdom.ts to support querySelector, attributes, and recursive parsing.\n- Mocked dompurify in src/__tests__/services/DocsService.test.ts to avoid dependency on full DOM implementation.\n- Preserved whitespace in MockDOMParser to fix markdown parsing tests.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @allenhutchison, 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 focuses on resolving failing tests within the workspace-mcp-server module by enhancing the testing environment. It introduces a custom JSDOM mock to provide a lightweight yet functional DOM for tests, and explicitly mocks DOMPurify to streamline test execution. These changes collectively ensure the stability and accuracy of tests related to HTML parsing and DOM manipulation, particularly for markdown content.

Highlights

  • Improved JSDOM Mock: A custom JSDOM mock has been introduced to provide essential DOM functionality for tests, including support for querySelector, attribute handling, and recursive parsing of HTML structures. This mock is now configured in jest.config.js.
  • DOMPurify Mocking: DOMPurify is now mocked in DocsService.test.ts to simplify test execution and remove dependencies on a full DOM implementation during testing, with its sanitize function returning the input content directly.
  • Whitespace Preservation in Mock DOM Parser: The custom MockDOMParser within the JSDOM mock has been designed to preserve whitespace, which was crucial for resolving issues and fixing markdown parsing tests.
  • Dependency Updates: Key dependencies such as jsdom, @types/jsdom, @asamuzakjp/dom-selector, cssstyle, decimal.js, parse5, whatwg-url, and ws have been updated to their latest versions, along with adjustments to jsdom's internal dependencies.
  • Repository URL Update: The repository URL in package.json has been updated from google-gemini/gemini-cli-workspace.git to gemini-cli-extensions/workspace.git.
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
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 failing tests by introducing a mock for jsdom and dompurify. The changes are well-targeted to solve the testing issues. The new jsdom mock is a good start, but I've identified a few areas where its robustness could be improved to make it more maintainable and less prone to breaking with future test changes. Specifically, I've commented on improving the implementation of textContent and querySelector, and fixing a potential bug in the HTML parsing regex to handle self-closing tags.

Comment thread workspace-mcp-server/src/__tests__/mocks/jsdom.ts
Comment thread workspace-mcp-server/src/__tests__/mocks/jsdom.ts Outdated
Comment thread workspace-mcp-server/src/__tests__/mocks/jsdom.ts
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@allenhutchison allenhutchison merged commit d7acd01 into main Nov 14, 2025
6 checks passed
@allenhutchison allenhutchison deleted the fix/jsdom-test-failures branch November 14, 2025 21:38
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.

2 participants