Skip to content

Commit 8b1a510

Browse files
authored
chore: convert mocha hooks cjs exports to esm exports (#4135)
1 parent f48f8d3 commit 8b1a510

File tree

6 files changed

+12
-16
lines changed

6 files changed

+12
-16
lines changed

.mocharc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"require": [
44
"source-map-support/register",
55
"ts-node/register",
6-
"test/tools/runner/chai-addons.js",
6+
"test/tools/runner/chai_addons.ts",
77
"test/tools/runner/hooks/unhandled_checker.ts"
88
],
99
"extension": [

test/mocha_mongodb.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"require": [
44
"source-map-support/register",
55
"ts-node/register",
6-
"test/tools/runner/chai-addons.js",
6+
"test/tools/runner/chai_addons.ts",
77
"test/tools/runner/hooks/configuration.ts",
88
"test/tools/runner/hooks/unhandled_checker.ts",
99
"test/tools/runner/hooks/leak_checker.ts",

test/tools/runner/chai-addons.js renamed to test/tools/runner/chai_addons.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
3+
import chai = require('chai');
24

3-
// configure chai
4-
const chai = require('chai');
55
chai.use(require('sinon-chai'));
66
chai.use(require('chai-subset'));
77
chai.use(require('../spec-runner/matcher').default);

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ const socketLeakCheckAfterEach: Mocha.AsyncFunc = async function socketLeakCheck
178178
const beforeAll = TRACE_SOCKETS ? [socketLeakCheckBeforeAll] : [];
179179
const beforeEach = [leakCheckerBeforeEach];
180180
const afterEach = [leakCheckerAfterEach, ...(TRACE_SOCKETS ? [socketLeakCheckAfterEach] : [])];
181-
module.exports = { mochaHooks: { beforeAll, beforeEach, afterEach } };
181+
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)