SyntaxError: Unexpected token when using react-script test


I created my project by create-react-app, and running test using its react-script test.

  • node version: 10.15.3
  • npm version: 6.4.1
  • react-scripts: 3.0.1

What happened?

When running test command (npm run test), I got this error message:

  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:


    import {adapterFactory} from './adapter_factory.js';

    SyntaxError: Unexpected token {

      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> (node_modules/react-qr-reader/lib/index.js:28:1)

Okay, it seems that jest would not transform files below node_modules. (And here is the jest config used by react-script: createJestConfig.js#L50)

Therefore, we need to overwrite that configure. Lots of information would tell you add transformIgnorePatterns config into package.json, but you will find you can’t do it with this error.

Out of the box, Create React App only supports overriding these Jest options:

  • collectCoverageFrom
  • coverageReporters
  • coverageThreshold
  • extraGlobals
  • globalSetup
  • globalTeardown
  • resetMocks
  • resetModules
  • snapshotSerializers
  • watchPathIgnorePatterns.

These options in your package.json Jest configuration are not currently supported by Create React App:

  • transformIgnorePatterns

If you wish to override other Jest options, you need to eject from the default setup. You can do so by running npm run eject but remember that this is a one-way operation. You may also file an issue with Create React App to discuss supporting more options out of the box.

error Command failed with exit code 1.
info Visit for documentation about this command.

but no worry, jest provide cli option for you, just add this into the test script command:

--transformIgnorePatterns 'node_modules/(?!(<package-need-to-transform>|<other-package-need-to-transform>)/)'

so it will become like this:

// package.json

  "scripts": {
    "test": react-scripts test --env=jsdom --transformIgnorePatterns 'node_modules/(?!(<package-need-to-transform>|<other-package-need-to-transform>)/)'

and jest will run without the SyntaxError. That’s it!


Signing for “name” requires a development team. Select a development team in the project editor. (in target ‘name’)

When developing iOS app, sometimes we might face this development team related problem:

Signing for "name" requires a development team. Select a development team in the project editor. (in target 'name')

This article is going to help you solve that problem.

Continue reading “Signing for “name” requires a development team. Select a development team in the project editor. (in target ‘name’)”

error: could not install smartsocket listener: Address already in use

This article is about error message: “error: could not install smartsocket listener: Address already in use”.

I like to flash my android smartphone. As we all know, there are (at lease) two tools we could use when flashing phones: adb and fastboot. But I met a problem when I try to run new adb server, it keep showing the this message in my terminal:

The Message “error: could not install smartsocket listener: Address already in use”

“Address already in use? so there must be someone using the address I need.” I thought, “ok, let me find the criminal”

and I gave terminal a command ps aux | grep adb to show all processes which is including adb word, then I got:


how to concat two mp4 files via command line

I want to concat two mp4 files together, so I found a command:

ffmpeg -i "concat:input1.mp4|input2.mp4|input3.mp4" -c copy output.mp4

But it doesn’t work. After my searching, I finally got the solution:

ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4

That’s it!