如何解决Jest 和 Commitize:即使测试失败,Commit 也能工作
我目前正在使用 Jest、Husky、Commitizen 和 Vuepress。但是,当玩笑测试或构建失败时,提交钩子仍然有效。当事情失败时,我该如何解决这个问题以退出 commitizen 钩子?这是 package.json 中的相关行:
{
"scripts": {
"build": "vuepress build docs
"lint": "eslint --fix --ext .js,.vue docs/.vuepress","test": "npm run lint && jest --coverage --coverageDirectory='__coverage__'","test:full": "npm run test && npm run build","commit": "cz",...
},"husky": {
"hooks": {
"prepare-commit-msg": "npm run test:full && exec < /dev/tty && git cz --hook || true"
}
},"dependencies": {
...
},"devDependencies": {
"babel-jest": "^26.6.3","commitizen": "^4.2.3","cz-conventional-changelog": "^3.3.0","eslint": "^7.18.0","husky": "^4.3.8","jest": "^26.6.3","config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
解决方法
想通了 - 这很简单。我需要向哈士奇添加以下内容:
$(document).ready(function () {
$('.filter').change(function () {
var values = [];
$('.filter option:selected').each(function () {
if ($(this).val() != "") values.push($(this).text());
});
filter('table > tbody > tr',values);
});
function filter(selector,values) {
$(selector).each(function () {
var sel = $(this);
var tokens = sel.text().split('\n');
var toknesObj = [],i;
for(i=0;i<tokens.length;i++){
toknesObj.push( {text:tokens[i].trim(),found:false});
}
var show = false;
console.log(values);
$.each(values,function (i,val) {
for(i=0;i<toknesObj.length;i++){
if (!toknesObj[i].found && toknesObj[i].text.search(new RegExp("\\b"+val+"\\b")) >= 0) {
toknesObj[i].found = true;
}
}
});
var count = 0;
$.each(toknesObj,val) {
if (val.found){
count+=1;
}
});
show = (count === values.length);
show ? sel.show() : sel.hide();
});
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。