We are using typescript
in node.js
We have a file called Sum.test.ts
that has this code
import { sum } from "./Sum"
This code run just fine when we do ts-node src/Sum.test.ts
BUT if we call the jest by npx jest src/Sum.test.ts
({“Object.”:function(module,exports,require,__dirname,__filename,jest){import
{ sum } from “./Sum”;
^^^^^^ SyntaxError: Cannot use import statement outside a module
This is the Sum.ts
file:
export function sum(a: number, b: number): number {
return a + b;
}
Any help would be appreciated.