Skip to content

Commit fc374d5

Browse files
committed
Fixed bug when specs checks for zeroed metric.
1 parent 1f1f4b3 commit fc374d5

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

lib/specs.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,11 @@ function specsRunner(specs, reporter, callback, err, data) {
120120
}
121121

122122
path.push(key);
123-
if (!data[key]) {
124-
tests.push({text: path.join('.'), result: new Error('not found')});
123+
if (data[key] === undefined || data[key] === null) {
124+
tests.push({
125+
text: path.join('.'),
126+
result: new Error('not found')
127+
});
125128
path.pop();
126129
return;
127130
}
@@ -130,7 +133,8 @@ function specsRunner(specs, reporter, callback, err, data) {
130133
if (typeof spec === 'object' && !spec.min && !spec.max) {
131134
traverse(spec, data[key]);
132135
} else if(typeof spec === 'number' && Array.isArray(data[key])) {
133-
tests.push(buildTest(path.join('.'), spec, data[key].length, defaults));
136+
tests.push(
137+
buildTest(path.join('.'), spec, data[key].length, defaults));
134138
path.pop();
135139
} else {
136140
tests.push(buildTest(path.join('.'), spec, data[key], defaults));

test/fixtures/specs.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
},
1717
"score_keep-alive": {
1818
"min": 90
19+
},
20+
"breakdown": {
21+
"css": {
22+
"requests": 2
23+
}
1924
}
2025
}
2126
}

0 commit comments

Comments
 (0)