monocart-coverage-reports 2.12.2 → 2.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli.js
CHANGED
|
@@ -93,10 +93,10 @@ const initNodeOptions = async (cliOptions) => {
|
|
|
93
93
|
// export source after
|
|
94
94
|
if (preloadType === '--import') {
|
|
95
95
|
const importPath = getRegisterPath('register.mjs');
|
|
96
|
-
nodeOptions.
|
|
96
|
+
nodeOptions.unshift(`--import ${importPath}`);
|
|
97
97
|
} else {
|
|
98
98
|
const requirePath = getRegisterPath('register.js');
|
|
99
|
-
nodeOptions.
|
|
99
|
+
nodeOptions.unshift(`--require ${requirePath}`);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// console.log(nodeOptions);
|
|
@@ -1037,7 +1037,7 @@ const initOriginalList = (state, originalDecodedMap, options) => {
|
|
|
1037
1037
|
// console.log(sourcePath);
|
|
1038
1038
|
|
|
1039
1039
|
// console.log(`add source: ${k}`);
|
|
1040
|
-
const sourceContent = sourcesContent[sourceIndex];
|
|
1040
|
+
const sourceContent = sourcesContent?.[sourceIndex];
|
|
1041
1041
|
if (typeof sourceContent !== 'string') {
|
|
1042
1042
|
Util.logError(`not found source content: ${sourcePath}`);
|
|
1043
1043
|
return;
|
|
@@ -1136,6 +1136,56 @@ const generateCoverageForDist = (state) => {
|
|
|
1136
1136
|
|
|
1137
1137
|
};
|
|
1138
1138
|
|
|
1139
|
+
const handleUncoveredInCovered = (state, originalStateMap) => {
|
|
1140
|
+
if (!state.fake) {
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// fake statements/branches/functions
|
|
1145
|
+
originalStateMap.forEach((originalState) => {
|
|
1146
|
+
const { bytes } = originalState;
|
|
1147
|
+
const list = [];
|
|
1148
|
+
originalState.bytes = bytes.filter((item) => {
|
|
1149
|
+
if (item.count === 0) {
|
|
1150
|
+
const range = bytes.find((it) => {
|
|
1151
|
+
if (it.count === 0) {
|
|
1152
|
+
return false;
|
|
1153
|
+
}
|
|
1154
|
+
if (it.start > item.end) {
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
if (it.end < item.start) {
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
return true;
|
|
1161
|
+
});
|
|
1162
|
+
if (range) {
|
|
1163
|
+
list.push(item);
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return true;
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
if (!list.length) {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
list.forEach((item) => {
|
|
1175
|
+
['statements', 'branches', 'functions'].forEach((key) => {
|
|
1176
|
+
originalState[key] = originalState[key].filter((it) => {
|
|
1177
|
+
if (it.start === item.start && it.end === item.end) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
return true;
|
|
1181
|
+
});
|
|
1182
|
+
});
|
|
1183
|
+
});
|
|
1184
|
+
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1139
1189
|
const unpackSourceMap = (state, options) => {
|
|
1140
1190
|
|
|
1141
1191
|
const { sourceMap, sourcePath } = state;
|
|
@@ -1186,6 +1236,9 @@ const unpackSourceMap = (state, options) => {
|
|
|
1186
1236
|
handleOriginalBytesCoverage(originalState);
|
|
1187
1237
|
});
|
|
1188
1238
|
|
|
1239
|
+
// remove uncovered in covered for fake
|
|
1240
|
+
handleUncoveredInCovered(state, originalStateMap);
|
|
1241
|
+
|
|
1189
1242
|
// collect coverage for original list
|
|
1190
1243
|
collectOriginalList(state, originalStateMap);
|
|
1191
1244
|
|