New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the "css" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. #617
Comments
Hi, Could you provide a repository where we can reproduce this bug? We are not able to reproduce all bugs by ourselves. Thanks :) |
@TMaszko My PR here https://github.com/reapit/foundations/pull/1303/files. This is public repo. So for the work around way is add |
Setup the Babel plugin like the error says https://github.com/callstack/linaria#setup Add the Linaria preset to your |
@satya164 I tried to set up babel.config.js and the error still appear. So that is the reason why I raise bug issue |
Make sure Jest is actually using your babel config. You have babel config at the root, but it's a monorepo, and jest probably doesn't read that babel config. |
@satya164 I also have config for the repo which I use linaria by extends from root config |
@tanphamhaiduong This could help https://jestjs.io/docs/en/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object |
There is 2 ways to solve this problem
|
What about mocking jest.mock("linaria/react", () => ({
styled: () => jest.fn(),
})); // WORKS
styled(Link)`
display: none;
`;
// NOT WORKING
styled.header`
display: none;
`; |
@jakeleboeuf this isn't a great solution but it does handle all the cases:
|
With // jest.config.js
module.exports = {
// [...]
globals: {
'ts-jest': {
babelConfig: true
}
}
}; |
I like this approach because (1) I want to use |
@turadg I found it does not work for wrapper |
I did this, but this did not solve the issue for me. |
This works for // jest.config.js
transform: {
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": "babel-jest", Use module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
["@babel/preset-react", { runtime: "automatic" }],
"linaria/babel",
],
}; |
Environment
Development
Description
-It run correct for webpack but cannot run in jest test snapshot
My webpack config
Reproducible Demo
http://g.recordit.co/f53GQ6OPWt.gif
The text was updated successfully, but these errors were encountered: