create-react-app-esbuild icon indicating copy to clipboard operation
create-react-app-esbuild copied to clipboard

Jest tests aren't working

Open grigory-bogush opened this issue 2 years ago • 3 comments

Compilation of the project works fine but as soon as try to run tests it fails with an odd syntax error that is not present when the craco-esbuild is disabled in craco.config.js. Perhaps there is a way to add this plugin for build & start leaving tests as is? Any help would be appreciated.

yarn test
yarn run v1.22.10
$ craco test --watchAll=false
 FAIL  src/utils/__test__/utils.spec.ts
  ● Test suite failed to run

    Transform failed with 1 error:
    <stdin>:59:4: error: Expected "}" but found ":"

      at failureErrorWithLog (node_modules/esbuild/lib/main.js:1443:15)
      at node_modules/esbuild/lib/main.js:1254:29
      at node_modules/esbuild/lib/main.js:606:9
      at handleIncomingPacket (node_modules/esbuild/lib/main.js:703:9)
      at readFromStdout (node_modules/esbuild/lib/main.js:573:7)
      at runServiceSync (node_modules/esbuild/lib/main.js:1808:3)
      at Object.transformSync (node_modules/esbuild/lib/main.js:1650:3)
      at Object.process (node_modules/esbuild-jest/esbuild-jest.js:54:36)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:464:35)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:569:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:607:25)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.565 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I am using react-scripts 4.0.3

grigory-bogush avatar Jul 13 '21 08:07 grigory-bogush

Happy to accept a pr to add an option for this :)

pradel avatar Jul 25 '21 10:07 pradel

Published as 0.3.3 thanks for the pr @grigory-bogush

pradel avatar Jul 25 '21 14:07 pradel

hey @grigory-bogush did you have any lead on why transformation fails? 🤔

yaronya avatar Aug 15 '21 08:08 yaronya