You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a test for the package-b which imports the package-a. The import fails, because the runtime tries to process javascript code instead of typescript:
FAIL src/index.spec.ts
● Test suite failed to run
Details:
/Users/user/repo/packages/package-a/out/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import * as Events from "./events";
Currently I'm able to fix this in 2 ways
Point package.jsons main to the typescript code
"main": "src/index.ts",
This is unacceptable, as this is not the correct way how to build TS npm package. It would be unusable from javascript, but this makes the test pass as the typescript is loaded.
Add transform option to the jest config
If I add a transform option to my jest config, to transform the js file from previous error
and supply a babel.config.js at the same time with
module.exports={presets: ["@babel/preset-env"],};
then the test passes, as it can now handle the javascript source.
This is my current solution, but this should be NOT required. the ts-jest should be able to work out of the box in this case.
Expected behavior :
I expect the ts-jest to load the monorepo package as a typescript package, not a javascript one. There is the types key ("types": "out/index.d.ts",) defined, so it should be used.
I don't want to add babel config, @babel/preset-env devDependency and transform option to each of my packages using typescript packages in the tests. This should work out of the box.
Debug log:
log file content
# content of ts-jest.log :
Minimal repo :
The text was updated successfully, but these errors were encountered:
Issue :
I have a monorepo of 2 typescript packages.
The second package depends on the first one.
I have a test for the
package-b
which imports thepackage-a
. The import fails, because the runtime tries to process javascript code instead of typescript:Currently I'm able to fix this in 2 ways
package.json
smain
to the typescript codeThis is unacceptable, as this is not the correct way how to build TS npm package. It would be unusable from javascript, but this makes the test pass as the typescript is loaded.
If I add a transform option to my jest config, to transform the
js
file from previous errorand supply a
babel.config.js
at the same time withthen the test passes, as it can now handle the javascript source.
This is my current solution, but this should be NOT required. the
ts-jest
should be able to work out of the box in this case.Expected behavior :
I expect the
ts-jest
to load the monorepo package as a typescript package, not a javascript one. There is the types key ("types": "out/index.d.ts",
) defined, so it should be used.I don't want to add babel config,
@babel/preset-env
devDependency and transform option to each of my packages using typescript packages in the tests. This should work out of the box.Debug log:
log file content
# content of ts-jest.log :
Minimal repo :
The text was updated successfully, but these errors were encountered: