-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test(7191): migrate integration/crud/document_validation
tests
#4714
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
base: main
Are you sure you want to change the base?
Conversation
|
||
// Ensure validation was correctly applied | ||
const err = await col.insertOne({ b: 1 }).catch(err => err); | ||
test.ok(err instanceof MongoServerError); |
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.
We use slightly different approach here to assert an error, in previous version it was test.ok(err != null);
and it worked well with callbacks, but with out current promise-based approach this won't work as err
will be initialized in both (successful and failed) scenarios.
const err = await col | ||
.updateOne({ b: 1 }, { $set: { b: 1 } }, { upsert: true }) | ||
.catch(err => err); | ||
expect(err).to.be.instanceOf(MongoServerError); |
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.
Same as above, the original test has expect(err).to.exist;
.
|
||
// Ensure validation was correctly applied | ||
const err = await col.insertOne({ b: 1 }).catch(err => err); | ||
test.ok(err instanceof MongoServerError); |
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.
Can we use chai for assertions here?
expect(err).to.be.instanceOf(MongoServerError)
Description
Summary of Changes
This PR migrates the integration tests for
crud/document_validation
. The changes include:src
folderNotes 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
npm run check:lint
)type(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript