Skip to content

Commit ba09897

Browse files
authored
test: Fix flaky tests for comment in MongoDB query (#9015)
1 parent 1ffc48f commit ba09897

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

spec/ParseQuery.Comment.spec.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const Config = require('../lib/Config');
4-
const TestUtils = require('../lib/TestUtils');
54
const { MongoClient } = require('mongodb');
65
const databaseURI = 'mongodb://localhost:27017/';
76
const request = require('../lib/request');
@@ -20,22 +19,33 @@ const masterKeyOptions = {
2019
json: true,
2120
};
2221

22+
const profileLevel = 2;
2323
describe_only_db('mongo')('Parse.Query with comment testing', () => {
24-
beforeEach(async () => {
24+
beforeAll(async () => {
2525
config = Config.get('test');
2626
client = await MongoClient.connect(databaseURI, {
2727
useNewUrlParser: true,
2828
useUnifiedTopology: true,
2929
});
3030
database = client.db('parseServerMongoAdapterTestDatabase');
31-
const level = 2;
32-
const profiling = await database.command({ profile: level });
33-
console.log(`profiling ${JSON.stringify(profiling)}`);
31+
let profiler = await database.command({ profile: 0 });
32+
expect(profiler.was).toEqual(0);
33+
console.log(`Disabling profiler : ${profiler.was}`);
34+
profiler = await database.command({ profile: profileLevel });
35+
profiler = await database.command({ profile: -1 });
36+
console.log(`Enabling profiler : ${profiler.was}`);
37+
profiler = await database.command({ profile: -1 });
38+
expect(profiler.was).toEqual(profileLevel);
39+
});
40+
41+
beforeEach(async () => {
42+
const profiler = await database.command({ profile: -1 });
43+
expect(profiler.was).toEqual(profileLevel);
3444
});
3545

36-
afterEach(async () => {
46+
afterAll(async () => {
47+
await database.command({ profile: 0 });
3748
await client.close();
38-
await TestUtils.destroyAllDataPermanently(false);
3949
});
4050

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

0 commit comments

Comments
 (0)