Jest does not work with macros -- `build` babel config is not used for `test`
See original GitHub issueCurrent Behavior
For example: Using styled-components/macros
breaks the test. Using styled-components
does not.
Suggested solution(s)
https://kulshekhar.github.io/ts-jest/user/config/babelConfig
Additional context
I can make a PR for this, but not sure how to tell it to find the babel config that tsdx uses
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
How does Jest give babel.rc to babel-jest? - Stack Overflow
I looked at the function getBabelRC , and by console.logging, I seem to confirm that the correct .babelrc (with plugin: macros) is loaded...
Read more >Babel Config option | ts-jest - GitHub Pages
ts-jest by default does NOT use Babel. ... The option is babelConfig and it works pretty much as the ... babelConfig: 'babelrc.test.js',
Read more >Getting Started - Jest
Note: Jest documentation uses yarn commands, but npm will also work. ... It will not use development section like Babel does by default...
Read more >Change Log - TSDX
The world's leading companies use TSDX to build and test TypeScript packages. ... use-cases like styled-components/macro , which previously did not work due ......
Read more >TypeScript With Babel: A Beautiful Marriage - I Am Turns
No problem, Babel converts the code and makes everything a-okay. ... ts-jest, ts-karma, create-react-app-typescript, etc, and use the Babel ...
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
@iDavidB I got it to work but it was quite a while ago… I’m just looking at the setup in my project… Maybe you need to add the
@babel/preset-env
to your.babelrc
… (Or since it was a while ago and I haven’t updated packages, possibly something has changed and the fix doesn’t work now for whatever reason.)So try adding the
@babel/preset-env
to your.babelrc
. I think without this, your babel config for testing doesn’t use@babel/preset-env
at all, and therefore might lack some necessary plugins (e.g. syntax plugins), which could be the source of your errors..babelrc
jest.config.js
Let me know if that does the trick! Otherwise, let us know what particular errors you are getting… It’s pretty hard to guess your problem without knowing the errors…
@ambroseus I was thinking the same, but I will need to untangle the config from that function. Haven’t done something like that before, should be fun