I cannot run any test command. They return same error, this is the first time i got this kind of error. I have tried config the jest but no use.
The error is:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\GITHUB\necter-backend\node_modules\wrap-ansi\index.js
require() of ES modules is not supported.
require() of D:\GITHUB\necter-backend\node_modules\wrap-ansi\index.js from D:\GITHUB\necter-
Here the package.json
{
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^9.4.2",
"@nestjs/config": "^2.3.2",
"@nestjs/core": "^9.4.2",
"@nestjs/jwt": "^10.0.3",
"@nestjs/mapped-types": "*",
"@nestjs/mongoose": "^9.2.2",
"@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^9.4.2",
"@nestjs/platform-socket.io": "^9.4.2",
"@nestjs/schedule": "^3.0.0",
"@nestjs/swagger": "^6.3.0",
"@nestjs/websockets": "^9.4.2",
"@types/passport-jwt": "^3.0.8",
...
},
"devDependencies": {
"@nestjs/testing": "^10.0.4",
"@types/jest": "^29.5.1",
"@types/node": "^20.2.4",
"@types/supertest": "^2.0.12",
"@types/validator": "^13.7.17",
"jest": "^29.5.0",
"nodemon": "^2.0.22",
"prettier": "^2.8.8",
"supertest": "^6.3.3",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"tslint": "6.1.3",
"typescript": "^5.0.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"engines": {
"node": ">=14.20.1"
}
}