Skip to content

Commit d73b537

Browse files
committed
chore: convert TS cjs exports to esm exports
1 parent f48f8d3 commit d73b537

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

test/tools/runner/hooks/configuration.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const testSkipBeforeEachHook = async function () {
107107
* @param skippedTests - define list of tests to skip
108108
* @returns
109109
*/
110-
const skipBrokenAuthTestBeforeEachHook = function (
110+
export const skipBrokenAuthTestBeforeEachHook = function (
111111
{ skippedTests }: { skippedTests: string[] } = { skippedTests: [] }
112112
) {
113113
return function () {
@@ -222,12 +222,8 @@ export function installNodeDNSWorkaroundHooks() {
222222
}
223223
}
224224

225-
module.exports = {
226-
mochaHooks: {
227-
beforeAll: [beforeAllPluginImports, testConfigBeforeHook],
228-
beforeEach: [testSkipBeforeEachHook],
229-
afterAll: [cleanUpMocksAfterHook]
230-
},
231-
skipBrokenAuthTestBeforeEachHook,
232-
installNodeDNSWorkaroundHooks
225+
export const mochaHooks = {
226+
beforeAll: [beforeAllPluginImports, testConfigBeforeHook],
227+
beforeEach: [testSkipBeforeEachHook],
228+
afterAll: [cleanUpMocksAfterHook]
233229
};

test/tools/runner/hooks/leak_checker.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,12 @@ class LeakChecker {
5555

5656
setupClientLeakChecker() {
5757
const leakChecker = this;
58-
MongoClient.prototype.connect = function (...args) {
58+
MongoClient.prototype.connect = async function () {
5959
leakChecker.clients.add(this);
6060
this[LeakChecker.kConnectCount] ??= 0;
61-
62-
const lastArg = args[args.length - 1];
63-
const lastArgIsCallback = typeof lastArg === 'function';
64-
if (lastArgIsCallback) {
65-
const argsWithoutCallback = args.slice(0, args.length - 1);
66-
return LeakChecker.originalConnect.call(this, ...argsWithoutCallback, (error, client) => {
67-
if (error == null) {
68-
this[LeakChecker.kConnectCount] += 1; // only increment on successful connects
69-
}
70-
return lastArg(error, client);
71-
});
72-
} else {
73-
return LeakChecker.originalConnect.call(this, ...args).then(client => {
74-
this[LeakChecker.kConnectCount] += 1; // only increment on successful connects
75-
return client;
76-
});
77-
}
61+
await LeakChecker.originalConnect.call(this);
62+
this[LeakChecker.kConnectCount] += 1; // only increment on successful connects
63+
return this;
7864
};
7965

8066
MongoClient.prototype.close = function (...args) {
@@ -178,4 +164,4 @@ const socketLeakCheckAfterEach: Mocha.AsyncFunc = async function socketLeakCheck
178164
const beforeAll = TRACE_SOCKETS ? [socketLeakCheckBeforeAll] : [];
179165
const beforeEach = [leakCheckerBeforeEach];
180166
const afterEach = [leakCheckerAfterEach, ...(TRACE_SOCKETS ? [socketLeakCheckAfterEach] : [])];
181-
module.exports = { mochaHooks: { beforeAll, beforeEach, afterEach } };
167+
export const mochaHooks = { beforeAll, beforeEach, afterEach };

test/tools/runner/hooks/unhandled_checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ function afterEachUnhandled() {
4141
unhandled.unknown = [];
4242
}
4343

44-
module.exports = { mochaHooks: { beforeEach: beforeEachUnhandled, afterEach: afterEachUnhandled } };
44+
export const mochaHooks = { beforeEach: beforeEachUnhandled, afterEach: afterEachUnhandled };

0 commit comments

Comments
 (0)