Jest coverage 正在报告以下代码中的 7 行和 8 条语句:
import * as React from 'react';
import { ReactComponent as Social } from './assets/social.svg';
export const mapCategory: React.FC<any> = (category: string) => {
const _category = category.toUpperCase();
switch (_category) {
case 'SOCIAL':
return <Social />;
default:
return <></>;
}
};
我不确定 Jest 的报道是如何解决这个问题的。有人能告诉我在提供的代码中什么算作行,什么算作语句吗?
似乎包含
switch
和default
关键字的行不算作行/语句。这是为什么?
switch (_category) { // THIS LINE
case 'DEVELOPMENT':
return <Development />;
default: // THIS LINE
return <></>;
}