I am currently implementing unit testing for a typescript project following the guidelines in this example: https://dev.to/muhajirdev/unit-testing-with-typescript-and-jest-2gln
In my project, I have a file named main.ts
that exports an isInternalLink
function.
Furthermore, there is a main.spec.ts
file where I attempt to test the function. However, I encounter the following error:
C:\data\devel\apps\tmp\jest-typescript\src\main.spec.ts:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { isInternalLink } from './main.js';
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
To access the complete example code, you can visit the public repository here:
If anyone has insights on resolving this issue or has a working example to share, I would greatly appreciate it.