Jestjs 通过Web包使用React组件运行jest时出现编译错误

Jestjs 通过Web包使用React组件运行jest时出现编译错误,jestjs,Jestjs,我在jest运行时遇到编译错误: SyntaxError: /usr/local/home/majioa/git/react-scroll-pagination/__tests__/index-test.js: Unexpected token (30:6) 28 | 29 | const reactScrollPagination = TestUtils.renderIntoDocument( > 30 | <ReactScrollPagination

我在jest运行时遇到编译错误:

SyntaxError: /usr/local/home/majioa/git/react-scroll-pagination/__tests__/index-test.js: Unexpected token (30:6)

  28 |
  29 |     const reactScrollPagination = TestUtils.renderIntoDocument(
> 30 |       <ReactScrollPagination />
     |       ^
  31 |     )
  32 |
  33 |     expect(mockConsoleError.calls.count()).toEqual(1)
以下是要复制的代码,即克隆,并在运行时执行npm测试/纱线测试

预期的测试运行已通过(部分),但

envinfo

$ node_modules/.bin/npx envinfo --preset jest
npx: установлен 1 в 4.763s

  System:
    OS: Linux 4.19 ALT Education 9.0
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
  Binaries:
    Node: 10.16.0 - /usr/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.14.4 - ~/git/react-scroll-pagination/node_modules/.bin/npm
  npmPackages:
    jest: ^25.2.3 => 25.2.3
那么如何解决这个问题呢

  "dependencies": {
    "prop-types": "^15.6.0",
    "react": "^16.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/plugin-proposal-class-properties": "7.8.3",
    "@babel/plugin-transform-react-inline-elements": "^7.9.0",
    "@babel/plugin-transform-runtime": "^7.9.0",
    "@babel/preset-env": "^7.9.0",
    "@babel/preset-react": "^7.9.1",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^25.2.3",
    "babel-loader": "^8.1.0",
    "eslint": "^6.8.0",
    "jasmine": "^3.5.0",
    "jest": "^25.2.3",
    "jest-cli": "^25.2.3",
    "jscs": "^3.0.7",
    "react-dom": "^16.0.0",
    "webpack": "^4.42.0",
    "webpack-cli": "^3.3.11"
  },
$ node_modules/.bin/npx envinfo --preset jest
npx: установлен 1 в 4.763s

  System:
    OS: Linux 4.19 ALT Education 9.0
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
  Binaries:
    Node: 10.16.0 - /usr/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.14.4 - ~/git/react-scroll-pagination/node_modules/.bin/npm
  npmPackages:
    jest: ^25.2.3 => 25.2.3