简体   繁体   English

运行玩笑反应测试时出错,无法识别玩笑

[英]Error running jest react test, jest not recognized

I'm trying to run some jest tests but keep getting the error: 我正在尝试进行一些开玩笑的测试,但不断收到错误消息:

'jest' is not recognized as an internal or external command, operable program or batch file. “笑话”未被识别为内部或外部命令,可操作程序或批处理文件。

Here is my package.json, can anyone please help get my test framework setup? 这是我的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": "*"
}
}

Looking closer at the errors, I had this: 仔细查看错误,我得到了:

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.

I fixed this with adding the version of the build tools when doing an npm install: 我在执行npm安装时通过添加构建工具的版本来解决此问题:

--msvs_version=2013

All works fine now. 现在一切正常。

You can also fix this by adding a system variable 您还可以通过添加系统变量来解决此问题

在此处输入图片说明

Install jest-cli. 安装jest-cli。 It worked for me. 它为我工作。 Just npm i jest-cli Test script should remain same "jest 只是npm我的jest-cli测试脚本应该保持不变

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行第一个 Jest/Puppeteer 测试时出现类型错误 - TypeError when running first Jest/Puppeteer test npm 测试/开玩笑不起作用 - npm test/ jest not working 运行“npm test”时没有控制台.log到STDOUT(开玩笑) - No console.log to STDOUT when running "npm test" (jest) VSCode Debug和Jest:没有使用npm运行的断点,CWD错误与节点一起运行 - VSCode Debug and Jest: No breakpoints running with npm, CWD error running with node 如何使用 Jest/Enzyme 在功能性 React 组件中测试 lambda 函数? - How to test lambda functions in a functional React Component using Jest/Enzyme? 对 Jest 测试设置时间限制? - Put time limit on Jest test? 在 Jest 中运行特定测试套件的单个测试 - Run single test of a specific test suite in Jest gulp-npm-test正在运行Jest测试(全部通过),但声称失败 - gulp-npm-test running Jest tests (all passing), but claiming to fail 使用 Powershell 通过 npm 脚本运行 Jest 测试时,转义引号和斜杠的正确方法是什么? - What is the proper way to escape quotes and slashes when running a Jest test with --collectCoverageFrom from Powershell via npm scripts? 通过玩笑运行测试,我在包含的.jsx文件中得到了“意外令牌” - Running test via jest, I get `Unexpected token` in included .jsx files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM