appvision-gmbh / json2typescript

Map JSON to a TypeScript class with secure type checking!
https://www.npmjs.com/package/json2typescript
MIT License
278 stars 55 forks source link

Jest - TypeError: json2typescript_1.JsonConvert is not a constructor #158

Closed iturn closed 3 years ago

iturn commented 3 years ago

All works well when in the NestJs and normal runtime, but while running in JEST it fails;

errpr
(node:11739) UnhandledPromiseRejectionWarning: TypeError: json2typescript_1.JsonConvert is not a constructor
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11739) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:11739) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

We have tried to work it out with je jest mapper config without success.

andreas-aeschlimann commented 3 years ago

If the test framework cannot compile the code, it is probably caused to the defined EcmaScript version. You could try the newest version of json2typescript (1.5.0-rc.0) which improved compatibility.

Please report back if this is still an issue.