Skip to content

Commit

Permalink
test: Fix flaky tests for comment in MongoDB query (#9015)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meglali20 committed Mar 15, 2024
1 parent 1ffc48f commit ba09897
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions spec/ParseQuery.Comment.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const Config = require('../lib/Config');
const TestUtils = require('../lib/TestUtils');
const { MongoClient } = require('mongodb');
const databaseURI = 'mongodb://localhost:27017/';
const request = require('../lib/request');
Expand All @@ -20,22 +19,33 @@ const masterKeyOptions = {
json: true,
};

const profileLevel = 2;
describe_only_db('mongo')('Parse.Query with comment testing', () => {
beforeEach(async () => {
beforeAll(async () => {
config = Config.get('test');
client = await MongoClient.connect(databaseURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
database = client.db('parseServerMongoAdapterTestDatabase');
const level = 2;
const profiling = await database.command({ profile: level });
console.log(`profiling ${JSON.stringify(profiling)}`);
let profiler = await database.command({ profile: 0 });
expect(profiler.was).toEqual(0);
console.log(`Disabling profiler : ${profiler.was}`);
profiler = await database.command({ profile: profileLevel });
profiler = await database.command({ profile: -1 });
console.log(`Enabling profiler : ${profiler.was}`);
profiler = await database.command({ profile: -1 });
expect(profiler.was).toEqual(profileLevel);
});

beforeEach(async () => {
const profiler = await database.command({ profile: -1 });
expect(profiler.was).toEqual(profileLevel);
});

afterEach(async () => {
afterAll(async () => {
await database.command({ profile: 0 });
await client.close();
await TestUtils.destroyAllDataPermanently(false);
});

it('send comment with query through REST', async () => {
Expand Down

0 comments on commit ba09897

Please sign in to comment.