mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
refactor: improve async operation handling in tests and enhance error handling in MongoDB wrapper
This commit is contained in:
@@ -4298,9 +4298,10 @@ Tinytest.addAsync(
|
||||
await Collection.updateAsync({ _id: 'a' }, { $set: { num: 1 } });
|
||||
await Collection.updateAsync({ _id: 'b' }, { $set: { num: 2 } });
|
||||
|
||||
if(Meteor.isClient) Meteor._sleepForMs(100); // wait for async operations to complete
|
||||
items = await Collection.find().fetchAsync();
|
||||
itemIds = items.map(_item => _item.num);
|
||||
|
||||
|
||||
test.equal(itemIds, [1, 2]);
|
||||
|
||||
await Collection.removeAsync({ _id: 'a' });
|
||||
|
||||
@@ -19,8 +19,6 @@ function connect(client) {
|
||||
|
||||
if (process.env.MONGO_URL && (/^mongodb(\+srv)?:\/\//.test(process.env.MONGO_URL))) {
|
||||
try {
|
||||
// Try to parse the connection string to check if it's valid
|
||||
new URL(process.env.MONGO_URL);
|
||||
connect(new MongoClient(process.env.MONGO_URL)).then(client => {
|
||||
if (client) client.close();
|
||||
});
|
||||
@@ -33,7 +31,7 @@ const useLegacyMongo = !!Package['npm-mongo-legacy']
|
||||
const oldNoDeprecationValue = process.noDeprecation;
|
||||
|
||||
useLegacyMongo && console.log('WARN: npm-mongo-legacy package detected, using package for mongo <= 3.6');
|
||||
|
||||
console.log('useLegacyMongo', useLegacyMongo);
|
||||
try {
|
||||
// Silence deprecation warnings introduced in a patch update to mongodb:
|
||||
// https://github.com/meteor/meteor/pull/9942#discussion_r218564879
|
||||
|
||||
@@ -74,7 +74,7 @@ export class TestCaseResults {
|
||||
var frame = stack[i];
|
||||
// Heuristic: use the OUTERMOST line which is in a :tests.js
|
||||
// file (this is less likely to be a test helper function).
|
||||
const fileName = frame.getFileName();
|
||||
const fileName = frame?.getFileName ? frame.getFileName() : null;
|
||||
if (fileName && fileName.match(/:tests\.js/)) {
|
||||
doc.filename = fileName;
|
||||
doc.line = frame.getLineNumber();
|
||||
|
||||
Reference in New Issue
Block a user