Skip to content

Commit

Permalink
chore: convert mocha hooks cjs exports to esm exports (#4135)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken authored Jul 2, 2024
1 parent f48f8d3 commit 8b1a510
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"require": [
"source-map-support/register",
"ts-node/register",
"test/tools/runner/chai-addons.js",
"test/tools/runner/chai_addons.ts",
"test/tools/runner/hooks/unhandled_checker.ts"
],
"extension": [
Expand Down
2 changes: 1 addition & 1 deletion test/mocha_mongodb.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"require": [
"source-map-support/register",
"ts-node/register",
"test/tools/runner/chai-addons.js",
"test/tools/runner/chai_addons.ts",
"test/tools/runner/hooks/configuration.ts",
"test/tools/runner/hooks/unhandled_checker.ts",
"test/tools/runner/hooks/leak_checker.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
/* eslint-disable @typescript-eslint/no-var-requires */

import chai = require('chai');

// configure chai
const chai = require('chai');
chai.use(require('sinon-chai'));
chai.use(require('chai-subset'));
chai.use(require('../spec-runner/matcher').default);
Expand Down
14 changes: 5 additions & 9 deletions test/tools/runner/hooks/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const testSkipBeforeEachHook = async function () {
* @param skippedTests - define list of tests to skip
* @returns
*/
const skipBrokenAuthTestBeforeEachHook = function (
export const skipBrokenAuthTestBeforeEachHook = function (
{ skippedTests }: { skippedTests: string[] } = { skippedTests: [] }
) {
return function () {
Expand Down Expand Up @@ -222,12 +222,8 @@ export function installNodeDNSWorkaroundHooks() {
}
}

module.exports = {
mochaHooks: {
beforeAll: [beforeAllPluginImports, testConfigBeforeHook],
beforeEach: [testSkipBeforeEachHook],
afterAll: [cleanUpMocksAfterHook]
},
skipBrokenAuthTestBeforeEachHook,
installNodeDNSWorkaroundHooks
export const mochaHooks = {
beforeAll: [beforeAllPluginImports, testConfigBeforeHook],
beforeEach: [testSkipBeforeEachHook],
afterAll: [cleanUpMocksAfterHook]
};
2 changes: 1 addition & 1 deletion test/tools/runner/hooks/leak_checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ const socketLeakCheckAfterEach: Mocha.AsyncFunc = async function socketLeakCheck
const beforeAll = TRACE_SOCKETS ? [socketLeakCheckBeforeAll] : [];
const beforeEach = [leakCheckerBeforeEach];
const afterEach = [leakCheckerAfterEach, ...(TRACE_SOCKETS ? [socketLeakCheckAfterEach] : [])];
module.exports = { mochaHooks: { beforeAll, beforeEach, afterEach } };
export const mochaHooks = { beforeAll, beforeEach, afterEach };
2 changes: 1 addition & 1 deletion test/tools/runner/hooks/unhandled_checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ function afterEachUnhandled() {
unhandled.unknown = [];
}

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

0 comments on commit 8b1a510

Please sign in to comment.