【问题标题】:Implement @emotion/babel-plugin with jest用 jest 实现 @emotion/babel-plugin
【发布时间】:2022-02-09 23:29:53
【问题描述】:

在我们的项目中,@emotion/babel-plugin 正常工作,但我们无法让它与 jest 一起工作,我们的 jest-preprocess 文件如下所示:

const babelJest = require('babel-jest');

const babelOptions = {
  presets: ['babel-preset-gatsby'],
  plugins: ['@emotion'],
};

module.exports = babelJest.default.createTransformer(babelOptions);

当我们运行测试时,我们会得到:

Component selectors can only be used in conjunction with @emotion/babel-plugin.

【问题讨论】:

    标签: javascript jestjs babeljs gatsby emotion


    【解决方案1】:

    您是否尝试过使用:

    // jest-preprocess.js
    const babelJest = require('babel-jest').default;
    
    const babelOptions = {
      presets: [
        "babel-preset-gatsby",
        "@emotion/babel-preset-css-prop",
      ],
      plugins: ["emotion"],
    }
    module.exports = babelJest.createTransformer(babelOptions)
    

    【讨论】:

      猜你喜欢
      • 2020-08-30
      • 1970-01-01
      • 2020-10-07
      • 2019-07-18
      • 2020-08-09
      • 2019-05-19
      • 2016-05-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多