linaria: Using the "css" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.
Environment
Development
- Linaria version: ^1.3.3
- Bundler (+ version): ^1.3.3
- Node.js version: v10.20.1
- OS: MacOS
Description
-It run correct for webpack but cannot run in jest test snapshot

My webpack config
...
{
test: /\.(ts|tsx)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
corejs: '3',
targets: {
esmodules: true,
chrome: '58',
ie: '11',
},
},
],
'linaria/babel',
],
},
},
{
loader: 'linaria/loader',
options: {
sourceMap: process.env.NODE_ENV !== 'production',
},
},
{ loader: 'ts-loader', options: { happyPackMode: true, transpileOnly: true } },
require.resolve('react-docgen-typescript-loader'),
],
},
{
test: /\.stories\.tsx?$/,
loaders: [
{
loader: require.resolve('@storybook/addon-storysource/loader'),
options: { parser: 'typescript' }
}
],
enforce: 'pre'
},
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV !== 'production',
},
},
{
loader: 'css-loader',
options: {
sourceMap: process.env.NODE_ENV !== 'production',
},
},
'sass-loader'
],
include: path.resolve(__dirname, '../')
},
...
Reproducible Demo
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (5 by maintainers)
@jakeleboeuf this isn’t a great solution but it does handle all the cases:
With
ts-jestyou can also active the babelConfig option which also solves the issue.What about mocking
styledfromlineria/react? I have a Gatsby build and am running into the same problem as @viczhuravlev here https://github.com/callstack/linaria/issues/636#issue-650266792. Attempting to slide by with some mocks, but not sure how to handle all cases…Setup the Babel plugin like the error says https://github.com/callstack/linaria#setup
Add the Linaria preset to your
babel.config.js@TMaszko My PR here https://github.com/reapit/foundations/pull/1303/files. This is public repo. So for the work around way is add
jest.mock('linaria')to the test