cleanup collections before starting tests

This commit is contained in:
Leonardo Venturini
2024-10-23 07:54:47 -04:00
parent cf5377742c
commit d6ce521432
2 changed files with 11 additions and 4 deletions

View File

@@ -109,7 +109,7 @@ Package.onTest(function (api) {
api.use('ecmascript');
api.use('npm-mongo', 'server');
api.use(['tinytest', 'test-helpers', 'ejson', 'random',
'ddp', 'base64']);
'ddp', 'base64', 'typescript']);
// XXX test order dependency: the allow_tests "partial allow" test
// fails if it is run before mongo_livedata_tests.
api.addFiles("mongo_livedata_tests.js", ["client", "server"]);

View File

@@ -12,7 +12,7 @@ export { Tinytest };
const handlesForRun = new Map;
const reportsForRun = new Map;
Meteor.publish(ServerTestResultsSubscription, function (runId) {
Meteor.publish(ServerTestResultsSubscription, async function (runId) {
check(runId, String);
if (! handlesForRun.has(runId)) {
@@ -36,9 +36,16 @@ Meteor.publish(ServerTestResultsSubscription, function (runId) {
});
Meteor.methods({
'tinytest/run'(runId, pathPrefix) {
async 'tinytest/run'(runId, pathPrefix) {
check(runId, String);
check(pathPrefix, Match.Optional([String]));
const collections = await MongoInternals.defaultRemoteCollectionDriver().mongo.db.collections();
for (const collection of collections) {
await collection.drop();
}
this.unblock();
reportsForRun.set(runId, Object.create(null));
@@ -84,4 +91,4 @@ Meteor.methods({
handlesForRun.delete(runId);
reportsForRun.delete(runId);
}
});
});