DocSpring / craco-antd

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

`craco test` fails #24

Open nirvdrum opened 4 years ago

nirvdrum commented 4 years ago

I've updated my package.json as shown in the test app, so I have:

"scripts": {
  "test": "craco test"
}

With this change, my test suite no longer runs. I went and checked out the craco-antd test app and I can't get yarn test to work there either. It looks like the less compiler isn't being invoked when it should :

 FAIL  src/App.test.tsx
  ● Test suite failed to run

    /home/nirvdrum/dev/workspaces/craco-antd/test-app/node_modules/antd/es/button/style/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import '../../style/index.less';
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      10 | };
      11 | 
    > 12 | class App extends Component<any, State> {
         | ^
      13 |   state: State;
      14 | 
      15 |   constructor(props: any) {

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
      at Object.<anonymous> (src/App.tsx:12:1)
filipjnc commented 4 years ago

The fix is here. Looking forward for the author to fix it.

nirvdrum commented 4 years ago

Thanks for letting me know there's a solution available.

alistairjcbrown commented 4 years ago

Has this issue been fixed now that PR #31 has landed and been released?

nirvdrum commented 4 years ago

I'll try it out shortly. I had been holding off on upgrading for #42. I wasn't sure if the releases on NPM were legitimate or a hacked account.