DocSpring / craco-antd

A craco plugin to use Ant Design with create-react-app
MIT License
234 stars 49 forks source link

craco test #48

Closed miguelc1221 closed 2 years ago

miguelc1221 commented 3 years ago

Not sure if it's related to this plugin but running craco test is not allowing my tests to pass. I am using create-react-app with typescript. I get the following error

node_modules/antd/lib/style/index.less:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){@import './themes/index';
                                                                                             ^

    SyntaxError: Invalid or unexpected token

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
      at Object.<anonymous> (node_modules/antd/lib/row/style/index.js:3:1)

This is what my config looks like

module.exports = {
  plugins: [
    {
      plugin: CracoAntDesignPlugin,
      options: {
        customizeTheme: antOverrides,
      },
    },
  ],
  jest: {
    configure: {
      transformIgnorePatterns: ['node_modules[/\\\\](?!@amcharts[/\\\\]amcharts4)'],
    },
  },
};
    "@craco/craco": "^5.7.0",
    "antd": "^4.6.4",
    "craco-antd": "^1.18.1",
gynekolog commented 3 years ago

Did you try instructions from Antd documentation?

package.json:

"jest": {
  "transformIgnorePatterns": [
    "/node_modules/(?!antd|@ant-design|rc-.+?|@babel/runtime).+(js|jsx)$"
  ]
}