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:
parent
52d1929cef
commit
0889548620
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"budget": {
|
||||
"timings": {
|
||||
"firstPaint": 5000
|
||||
"requests": {
|
||||
"httpErrors": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue