Closed gtbono closed 3 years ago
Jest ships with one transformer out of the box - babel-jest It will automatically load your project's Babel configuration and transform any file matching the following RegEx: /.[jt]sx?$/ meaning any .js, .jsx, .ts and .tsx file.
means you can just run your test-fiels with jest without thinking about transpilation
if you have a custom jest config, you probably need to add the transformer option back
transform: { '\.(js|ts|jsx|tsx)$': 'babel-jest', }
hi @firsttris !
this was exactly what I needed, I used the ts-jest
transformer
thanks! :)
Hello,
I don't know if my use case is possible, but I will try to describe it here.
I'm using Node.js and TypeScript, but I don't run ts-node or ts-jest, I'm running tsc before testing.
I have my tests in
myproject/tests/unit/unit_test.ts
But they compile using tsc to:
myproject/dist/tests/unit/unit_test.js
So my jest config is as follows:
And to run, I run
npm run test
, with the following configuration:So when I run
npm run test
, it compiles my test todist
folder, andjest
picks up the tests from there.But here's my problem, when I run the tests from the extension, I could change my Jest executable, so they run the following command:
But because of my Jest config, it can't find my tests, because I would need to strip out the
.ts
extension from the test (or change to .js) and run them from the Jest root dir folder, like:But I don't know if the extension provides something for me to configure this, or if I can achieve what I need by changing my Jest config, do you have any idea how I could do it? if you need any more info please ask me