I am trying to run jest test cases but I am facing error -
ReferenceError: TextEncoder is not defined .
Node version -14.18.0.
Mongodb NPM - 4.1.3 .
Typescript version - 4.4.3.
Below is my test code --
beforeAll(() => {
connection = new Connection();
});
Below is my connection class code
import { MongoClient, Db, MongoClientOptions } from 'mongodb';
class MongoConnection {
public async conn(){
await MongoClient.connect('', options);
}
}
Error --
FAIL connection.test.ts
● Test suite failed to run
ReferenceError: TextEncoder is not defined > 1 | import { MongoClient, Db, MongoClientOptions } from 'mongodb';