【问题标题】:Error running jest react test, jest not recognized运行 jest react 测试时出错,jest 无法识别
【发布时间】:2015-07-31 00:46:39
【问题描述】:

我正在尝试运行一些笑话测试,但不断收到错误:

'jest' 不是内部或外部命令、可运行程序或批处理文件。

这是我的 package.json,谁能帮忙设置我的测试框架?

{
 "name": "lac-react",
 "version": "0.0.0",
 "description": "",
 "main": "index.js",
 "scripts": {
 "test": "jest"
},
 "author": "",
 "license": "ISC",
 "devDependencies": {
  "browserify": "^9.0.8",
  "gulp": "^3.8.11",
  "gulp-concat": "^2.5.2",
  "gulp-cssmin": "^0.1.7",
  "gulp-react": "^3.0.1",
  "gulp-rename": "^1.2.2",
  "gulp-streamify": "0.0.5",
  "gulp-uglify": "^1.2.0",
  "gulp-watch": "^4.2.4",
  "reactify": "^1.1.0",
  "vinyl-source-stream": "^1.1.0",
  "watchify": "^3.2.1"
},
"jest": {
  "scriptPreprocessor": "./preprocessor.js",
  "unmockedModulePathPatterns": [
    "react"
  ],
  "testPathDirs": [
    "./src/components/__tests__/"
  ]
},
"dependencies": {
  "moment": "^2.10.2",
  "react": "^0.13.2",
  "react-datepicker": "^0.6.2",
  "react-message": "^1.3.0",
  "react-router": "^0.13.3",
  "react-skylight": "^0.2.0",
  "superagent": "^1.2.0",
  "react": "*",
  "react-tools": "*",
  "jest-cli": "*"
}
}

【问题讨论】:

    标签: npm reactjs jestjs


    【解决方案1】:

    仔细查看错误,我有这个:

    error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, p lease install Visual Studio 2010 build tools.
    

    我通过在执行 npm 安装时添加构建工具的版本来解决此问题:

    --msvs_version=2013
    

    现在一切正常。

    您也可以通过添加系统变量来解决此问题

    【讨论】:

      【解决方案2】:

      安装 jest-cli。它对我有用。 只是 npm i jest-cli 测试脚本应该保持不变“开玩笑

      【讨论】:

      • 您好,感谢您的回答。但是,由于您没有使用任何格式,因此它的阅读效果不太好,并且不清楚 Test script 应该保持相同“jest 的含义是什么
      猜你喜欢
      • 1970-01-01
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      • 2019-07-08
      • 2021-10-15
      • 2019-02-06
      • 1970-01-01
      • 2019-09-06
      相关资源
      最近更新 更多