Skip to content

Conversation

tadjik1
Copy link
Member

@tadjik1 tadjik1 commented Oct 13, 2025

Description

Summary of Changes

This PR migrates the integration tests for crud/find. The changes include:

  • Convert file in typescript
  • Refactor callbacks to async/await
  • Direct import from the src folder
  • Mark outdated tests for later removal
  • Add assertions to some tests
Notes for Reviewers

To simplify the review process there is a separate commit for .js -> .ts conversion.

What is the motivation for this change?

This work is part of a larger, ongoing initiative to convert all tests to use async/await, with the ultimate goal of removing the legacy driver wrapper.

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@tadjik1 tadjik1 marked this pull request as ready for review October 13, 2025 13:44
@tadjik1 tadjik1 requested a review from a team as a code owner October 13, 2025 13:44
Comment on lines +929 to +950
it.skip('should correctly iterate over collection', async function () {
const db = client.db(this.configuration.db);

const collection = db.collection('shouldCorrectlyIterateOverCollection');
// Insert 500 documents
const docsToInsert = Array.from({ length: 500 }, () => ({
a: 1,
b: 2,
c: { d: 3, f: 'sfdsffffffffffffffffffffffffffffff' }
}));
await collection.insertMany(docsToInsert);

let iteratedCount = 0;
const cursor = collection.find({});

for await (const doc of cursor) {
expect(doc).to.exist;
iteratedCount++;
}

expect(iteratedCount).to.equal(500);
}).skipReason = 'TODO(NODE-3819): flaky tests (on macOS)';
Copy link
Member Author

Choose a reason for hiding this comment

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

Even though the test is skipped I took an opportunity to refactor it as well, maybe we can unskip it now as most probably it won't be flaky.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with giving it a try; go for it!

@baileympearson baileympearson self-assigned this Oct 13, 2025
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Oct 13, 2025
Copy link
Contributor

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

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

Just a few small comments. What a large PR!

});
});
it('should correctly perform find by $where', {
metadata: { requires: { mongodb: '4.2.x' } },
Copy link
Contributor

Choose a reason for hiding this comment

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

4.2 is our lowest tested server version - suggest removing metadata entirely

});
});
});
it('should execute query using limit of 101', async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('should execute query using limit of 101', async function () {
it('should execute query using limit of 200', async function () {

we may as well align the title with the test 🤷

});
});
}
it('Should correctly apply db level options to find cursor', async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest either removing this, or fixing it. as it is written, the test always passes (insert two docs, fetch all docs, assert two docs fetched)

Comment on lines +929 to +950
it.skip('should correctly iterate over collection', async function () {
const db = client.db(this.configuration.db);

const collection = db.collection('shouldCorrectlyIterateOverCollection');
// Insert 500 documents
const docsToInsert = Array.from({ length: 500 }, () => ({
a: 1,
b: 2,
c: { d: 3, f: 'sfdsffffffffffffffffffffffffffffff' }
}));
await collection.insertMany(docsToInsert);

let iteratedCount = 0;
const cursor = collection.find({});

for await (const doc of cursor) {
expect(doc).to.exist;
iteratedCount++;
}

expect(iteratedCount).to.equal(500);
}).skipReason = 'TODO(NODE-3819): flaky tests (on macOS)';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with giving it a try; go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Primary Review In Review with primary reviewer, not yet ready for team's eyes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants