Skip to content

Commit 9919544

Browse files
committed
Fix chai usage for chai5/chaihttp5
As chai only supports esm, not commjs since v5, adjust the setup code to use dynamic imports. See chaijs/chai#1578 for more. Change-Id: I3c34043504bdf0c881eed4dabbe9e4fc8bb0b362
1 parent cc3afdb commit 9919544

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/config/pretest.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
//NOTE: Here we load and initialize some global variables that are used throughout the tests
33
require("dotenv").config();
4-
var chaiHttp = require("chai-http");
4+
var chaiHttp;
5+
var chai;
56

67
const { MongoClient } = require("mongodb");
78

89
const client = new MongoClient(process.env.MONGODB_URI);
910

1011
async function loadChai() {
11-
const { chai } = import("chai");
12-
chai.use(chaiHttp);
12+
chaiHttp = await import("chai-http");
13+
await import("chai").then((result) => {
14+
chai = result.use(chaiHttp);
15+
});
1316
await client.connect();
1417
}
1518

0 commit comments

Comments
 (0)