Skip to content

Mongosh test suite PoC #49

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

Merged
merged 4 commits into from
Jun 27, 2025
Merged

Conversation

dacharyc
Copy link
Collaborator

@dacharyc dacharyc commented Jun 24, 2025

This PR moves the existing JavaScript Node.js test suite into a driver directory, and adds a second mongosh directory under JavaScript with a PoC for testing mongosh code examples with Jest.

After some trial and error, I found the best way to execute the existing code examples with minimal modification was to use the Execute a Script from the Command Line option from the mongosh docs.

This PoC tests the code examples on the $group reference page.

Copy link
Collaborator

@cbullinger cbullinger left a comment

Choose a reason for hiding this comment

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

🚀 excited for this!

operations that remain open after the tests are complete. These can cause the test suite
to hang, and this flag tells Jest to report info about these instances.

#### Run Test Suites from the command line
Copy link
Collaborator

Choose a reason for hiding this comment

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

why aren't we using npm scripts here? would let us simplify these last sections to running the following from /mongosh root without requiring jest installed:

npm test -- -t '<text string from the 'describe()' block you want to run>'

or

npm test -- -t '<text string from the 'it()' block you want to run>'

...if we do keep them as a jest commands, we should:

  • add jest install to prereqs (npm install -g jest)
  • drop the export since it's not needed -- the setup already handles it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call! I did not know this was an option 😅 Updated!

const port = process.env.CONNECTION_PORT;
const dbName = "test";

// Load test data before running the tests
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems like this will help enforce using standardized sample data across examples too

dacharyc and others added 2 commits June 27, 2025 15:25
Co-authored-by: Cory <115956901+cbullinger@users.noreply.github.com>
@dacharyc dacharyc merged commit e13a2cb into mongodb:main Jun 27, 2025
@dacharyc dacharyc deleted the mongosh-test-suite-poc branch June 27, 2025 19:44
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