node.js - jest 和 npm 没有运行测试,只是挂起
问题描述
我对 node.js 不熟悉,因为我还在学习前端,但是我已经开始通过 exercism.com 练习前端,这需要您使用 npm 和 jest 通过他们的测试套件运行测试。所以我真的很没面子,没有人可以问,希望能得到一些答案。
我正在尝试在 Windows 10 的 git bash 中运行命令“npm test”。当我运行前几个测试时,它运行良好,只有一个测试要运行,因为其他测试被阻止了。当我在所有条件下运行测试时,它开始出现这个问题。我用谷歌搜索了很多,这是我尝试过的:
- 更新节点
- 更新笑话
- 运行 -i
- 运行--runInBand
- 运行 -i和--runInBand
它只是挂起。最后一行如下所示:
开玩笑--no-cache ./*
真正的关键在于:我可以在我之前的任何练习中运行 npm test,它运行得很好。我真的很想了解这里的问题。我不知道需要分享哪些信息,所以这似乎是相关的:
$节点-v v11.13.0
$开玩笑-v 25.5.4
package.json 文件:
{
"name": "exercism-javascript",
"description": "Exercism exercises in Javascript.",
"author": "Katrina Owen",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/javascript"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/preset-env": "^7.9.6",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.4",
"babel-eslint": "^10.1.0",
"babel-jest": "^25.5.1",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.2",
"jest": "^25.5.4"
},
"jest": {
"modulePathIgnorePatterns": [
"package.json"
]
},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"license": "MIT",
"dependencies": {}
}
这是测试文件,显示测试前面没有“x”:
import { steps } from './collatz-conjecture';
describe('steps()', () => {
test('zero steps for one', () => {
expect(steps(1)).toEqual(0);
});
test('divide if even', () => {
expect(steps(16)).toEqual(4);
});
test('even and odd steps', () => {
expect(steps(12)).toEqual(9);
});
test('Large number of even and odd steps', () => {
expect(steps(1000000)).toEqual(152);
});
test('zero is an error', () => {
expect(() => {
steps(0);
}).toThrow(new Error('Only positive numbers are allowed'));
});
test('negative value is an error', () => {
expect(() => {
steps(-15);
}).toThrow(new Error('Only positive numbers are allowed'));
});
});
谢谢!
解决方案
推荐阅读
- php - 在 codeigniter4 的模型中使用 $dateFormat INT
- apache-kafka - 从命令提示符创建 Kafka 生产者给代理断开错误
- r - 将文本字符串“ABCYYYYMM”转换为 R 中的日期格式
- php - 上传文件时响应文件管理器显示未知错误
- wcf - 如何确保将客户端证书传递给服务器
- python - 我如何知道函数返回的是字符串还是字节?
- c++ - 编译错误:匿名聚合中不允许使用构造函数的成员
- amazon-web-services - 如何在 AWS ECS 集群的服务中运行 AWS ECS 任务,而不是将服务从 Circle CI 的“aws-ecs/run-task”中排除
- javascript - 当另一个菜单项的按钮(第一个的“表亲”)被使用 Javascript 而没有 jQuery 点击时,关闭一个菜单项的子菜单
- android - kotlin - 我的 if 语句和运算符有问题