feat - verify http status in budget (and log errors) (#2691)

on budget verify, check for responseCode from
pagesummary and log any status code > 399
configure budget httpErrors = 0
This commit is contained in:
thapasya-m 2019-10-11 00:00:59 +05:30 committed by Peter Hedenskog
parent 52d1929cef
commit 0889548620
4 changed files with 20 additions and 3 deletions

View File

@ -22,7 +22,8 @@ module.exports = {
javascript: 'contentTypes.javascript.requests',
css: 'contentTypes.css.requests',
image: 'contentTypes.image.requests',
font: 'contentTypes.font.requests'
font: 'contentTypes.font.requests',
httpErrors: 'responseCodes'
},
transferSize: {
total: 'transferSize',

View File

@ -61,6 +61,10 @@ module.exports = {
if (value && message.type === 'lighthouse.pageSummary') {
value = value * 100; // The score in Lighthouse is 0-1
}
if (value && message.type === 'pagexray.pageSummary') {
// count number of http server error
value = Object.keys(value).filter(code => code > 399).length;
}
// We got a matching metric
if (value) {
const budgetValue = budgetForThisURL[metricType][metric];

View File

@ -74,6 +74,18 @@ module.exports = {
: undefined
};
const pageSummary = pagexray.convert(message.data, config);
//check and print any http server error > 399
for (let summary of pageSummary) {
if (Object.keys(summary.responseCodes).some(code => code > 399)) {
for (let asset of summary.assets) {
log.info(
`Error: The server responded with a ${
asset.status
} status code for ${asset.url}`
);
}
}
}
pagexrayAggregator.addToAggregate(pageSummary, group);
if (this.multi) {

View File

@ -1,7 +1,7 @@
{
"budget": {
"timings": {
"firstPaint": 5000
"requests": {
"httpErrors": 0
}
}
}