Closed HamedFathi closed 3 years ago
As far as I know, the "transform" section is different from "moduleNameMapper".
In transform, jest calls the transformer to process the content of the requested file. In moduleNameMapper, jest use the target file content as if it's the content of the requested file.
So when you use "...": "jest-transform-stub"
, it uses the main file of the npm module jest-transform-stub as the content of any css/less/scss file. You can almost replace "...": "jest-transform-stub"
with any "...": "any-npm-module"
as long as importing any-npm-module
has no serious side effect at runtime when jest runs test.
Please share a minimal repo where you have problem with webpack+jest.
Please share a minimal repo where you have problem with webpack+jest.
So weird, I cannot reproduce it again! but I have added that config into our project right now (I cannot share it). I made a local project and it is OK!
Based on Jest doc for Webpack and also my recent experience
we should move/copy
under
moduleNameMapper
Two points:
"^.+\\.ts$": "ts-jest"
or not!transform
section or not?cc @3cp