Different TS-JEST / TS emitted code when importing 3rd party libs
See original GitHub issueContinuing the discussion from issue 209
For the same code compiled with TS, ts-jest emits a different output.
- Both tsconfig file are identical (one for regular TS compilation, one for ts-jest)
allowSyntheticDefaultImports
set to true.
When using this statement:
import * as pathToRegexp from 'path-to-regexp';
In TS compilation without ts-jest
pathToRegexp is a function
In TS compilation with ts-jest
pathToRegexp is an object.
It’s not deterministic, different outcome for the same TS compilation process
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (9 by maintainers)
Top Results From Across the Web
Jest fails when importing a 3rd party non TS module
I am using an internal 3rd party Design system library, we will call it (3DS) to render components. The 3DS library doesn't support ......
Read more >Configuring Jest
To read TypeScript configuration files Jest requires ts-node . ... This option tells Jest that all imported modules in your tests should be ......
Read more >TypeScript library tips: Rollup your types! | by Martin Hochel
Our whole library tree structure is mirrored by emitted declaration .d.ts files. While we have optimized runtime by rollup-ing our source code ......
Read more >React app testing: Jest and React Testing Library
Learn how to test React applications with Jest and React Testing Library, a popular combination and official recommendation from React.
Read more >jest-preset-angular - npm
By Angular CLI defaults you'll have a src/test.ts file which will be picked up by jest. To circumvent this you can either rename...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another thing going for option 2 is that it makes sure the users know what’s going on.
Currently, as you pointed out as well, users have no idea that ts-jest uses babel when
allowSyntheticDefaultImports
is set to true. It’s also not very intuitive. If I came across something like this in another library, I’d be at my wits end should something related go wrong and I have to debug it!It is a breaking change but the fix required at the users’ end would be straightforward - set
transformUsingBabel
to true in ts-jest config. This would also give us an opportunity to introduce thets-jest
config within thejest
config which can be used by #217 later.Currently babel is only used when allowSyntheticDefaultImports is set to true, so it covers all cases. I imagine if we end up using babel for every transformation we will make them independent
On Wed, May 24, 2017, 20:43 jupl notifications@github.com wrote:
– mvh.
Gustav Wengel