-
Notifications
You must be signed in to change notification settings - Fork 85
chore: add ability to run tests in VSCode UI with Mocha Test Explorer #2597
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds VSCode multi-root workspace configuration to enable running and debugging mongosh tests directly within VSCode using the Mocha Test Explorer extension. The changes refactor test configurations from inline package.json scripts to separate .mocharc.json files for better organization and IDE integration.
- Extracted Mocha test configurations from package.json scripts into dedicated .mocharc.json files across all packages
- Created a multi-root workspace file (mongosh.code-workspace) that includes all packages as separate folders
- Added a dummy test file to support the Mocha Test Explorer functionality
Reviewed changes
Copilot reviewed 53 out of 54 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| mongosh.code-workspace | Multi-root workspace configuration listing all packages and Mocha Test Explorer settings |
| testing/dummy.spec.ts | Placeholder test file for Mocha Test Explorer compatibility |
| packages/*/package.json | Simplified test scripts to use mocha command |
| packages/*/.mocharc.json | New configuration files containing previously inline Mocha options |
| .mocharc.json | Root-level Mocha configuration pointing to dummy test |
| package.json | Added chai-as-promised dependency |
| packages/browser-repl/src/iframe-runtime/iframe-runtime.spec.ts | Added type assertions for improved type safety |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
addaleax
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I think Copilot's comments are correct, plus one suggestion re: maintaining the workspace config file
| let runtime; | ||
| let serviceProvider; | ||
| let runtime: IframeRuntime; | ||
| let serviceProvider: ServiceProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💙
| { | ||
| "name": "📦 @mongosh/browser-repl", | ||
| "path": "packages/browser-repl" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should ./scripts/sort-workspaces also update this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea
lerouxb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gimme gimme gimme
dd0e0e7 to
8edcbd8
Compare
This accomplishes my long term dream of being able to debug and run mongosh tests right from inside VSCode.
It does so through a multi-root workspace which you can open by navigating to
mongosh.code-workspaceand clicking open.After installing the recommended https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter you should be able to run tests in UI and debugging!
Some have their quirks i.e.

async-rewriter2needs experimental vm mode etc. but overall I have been using this for a few days and feel much more productive!