小编Ait*_*usi的帖子

用Create React App开玩笑:测试套件无法运行-意外令牌

开箱即用的带有笑话的create-react-app总是失败

我做过的步骤

create-react-app cra-test
cd cra-test
yarn install
Run Code Online (Sandbox Code Playgroud)

原来testpackage.json变成了

{
  "name": "cra-test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "jest",
    "eject": "react-scripts eject"
  }
}
Run Code Online (Sandbox Code Playgroud)

当我运行yarn test测试失败。这是输出

yarn run v1.1.0
$ jest
FAIL  src\App.test.js
  ? Test suite failed to run

    .../cra-test/src/App.test.js: Unexpected token (7:18)
         5 | it('renders without crashing', () => {
         6 |   const div = document.createElement('div');
      > …
Run Code Online (Sandbox Code Playgroud)

node.js reactjs jestjs create-react-app yarnpkg

6
推荐指数
1
解决办法
2144
查看次数

标签 统计

create-react-app ×1

jestjs ×1

node.js ×1

reactjs ×1

yarnpkg ×1