From d713e44f143e54844f61e6f7dc4173d917dcc2de Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Wed, 10 Jan 2018 14:08:47 -0800 Subject: [PATCH] tests: remove global timeout, set timeouts individually (#4224) --- lighthouse-core/lib/traces/trace-parser.js | 1 + lighthouse-core/scripts/run-mocha.sh | 2 +- lighthouse-core/test/audits/bootup-time-test.js | 2 +- lighthouse-core/test/audits/screenshot-thumbnails-test.js | 2 +- lighthouse-core/test/audits/speed-index-metric-test.js | 2 +- lighthouse-core/test/gather/computed/dtm-model-test.js | 2 +- lighthouse-core/test/gather/computed/speedline-test.js | 8 ++++---- lighthouse-core/test/lib/asset-saver-test.js | 4 ++-- lighthouse-core/test/lib/traces/trace-parser-test.js | 4 ++-- 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lighthouse-core/lib/traces/trace-parser.js b/lighthouse-core/lib/traces/trace-parser.js index 150a523ebc..6b6cb23292 100644 --- a/lighthouse-core/lib/traces/trace-parser.js +++ b/lighthouse-core/lib/traces/trace-parser.js @@ -14,6 +14,7 @@ const WebInspector = require('../web-inspector'); * streaming JSON parser. * The resulting trace doesn't include the "metadata" property, as it's excluded via DevTools' * implementation. + * FIXME: This can be removed once Node 8 support is dropped. https://stackoverflow.com/a/47781288/89484 */ class TraceParser { constructor() { diff --git a/lighthouse-core/scripts/run-mocha.sh b/lighthouse-core/scripts/run-mocha.sh index f1f33c7506..3efd8846e4 100755 --- a/lighthouse-core/scripts/run-mocha.sh +++ b/lighthouse-core/scripts/run-mocha.sh @@ -9,7 +9,7 @@ flag=$1 function _runmocha() { - mocha --reporter dot $2 $(find $1/test -name '*-test.js') --timeout 60000; + mocha --reporter dot $2 $(find $1/test -name '*-test.js'); } if [ "$flag" == '--watch' ]; then diff --git a/lighthouse-core/test/audits/bootup-time-test.js b/lighthouse-core/test/audits/bootup-time-test.js index 0b4a837de6..f3dac6a077 100644 --- a/lighthouse-core/test/audits/bootup-time-test.js +++ b/lighthouse-core/test/audits/bootup-time-test.js @@ -43,7 +43,7 @@ describe('Performance: bootup-time audit', () => { assert.deepEqual(roundedValueOf('https://pwa.rocks/'), {[groupIdToName.parseHTML]: 14.2, [groupIdToName.scripting]: 6.1, [groupIdToName.scriptParseCompile]: 1.2}); assert.deepEqual(roundedValueOf('https://pwa.rocks/0ff789bf.js'), {[groupIdToName.parseHTML]: 0}); }); - }); + }).timeout(10000); it('should get no data when no events are present', () => { const artifacts = Object.assign({ diff --git a/lighthouse-core/test/audits/screenshot-thumbnails-test.js b/lighthouse-core/test/audits/screenshot-thumbnails-test.js index 568adc2e1e..e15c76939c 100644 --- a/lighthouse-core/test/audits/screenshot-thumbnails-test.js +++ b/lighthouse-core/test/audits/screenshot-thumbnails-test.js @@ -63,7 +63,7 @@ describe('Screenshot thumbnails', () => { assert.equal(results.details.items[9].timing, 818); assert.equal(results.details.items[0].timestamp, 225414253815); }); - }); + }).timeout(10000); it('should scale the timeline to TTFI', () => { const artifacts = Object.assign({ diff --git a/lighthouse-core/test/audits/speed-index-metric-test.js b/lighthouse-core/test/audits/speed-index-metric-test.js index 0ee9969500..81ff3d9418 100644 --- a/lighthouse-core/test/audits/speed-index-metric-test.js +++ b/lighthouse-core/test/audits/speed-index-metric-test.js @@ -49,7 +49,7 @@ describe('Performance: speed-index-metric audit', () => { assert.equal(Math.round(result.extendedInfo.value.timings.visuallyComplete), 1105); assert.equal(Math.round(result.extendedInfo.value.timings.perceptualSpeedIndex), 609); }); - }); + }).timeout(10000); it('throws an error if no frames', () => { const artifacts = mockArtifactsWithSpeedlineResult({frames: []}); diff --git a/lighthouse-core/test/gather/computed/dtm-model-test.js b/lighthouse-core/test/gather/computed/dtm-model-test.js index 5e24009b2b..9c96c592bd 100644 --- a/lighthouse-core/test/gather/computed/dtm-model-test.js +++ b/lighthouse-core/test/gather/computed/dtm-model-test.js @@ -77,5 +77,5 @@ describe('DTM Model gatherer', () => { assert.deepStrictEqual(pwaTrace[i], freshTrace[i]); } }); - }); + }).timeout(20000); }); diff --git a/lighthouse-core/test/gather/computed/speedline-test.js b/lighthouse-core/test/gather/computed/speedline-test.js index 0e05ca874e..112c15431b 100644 --- a/lighthouse-core/test/gather/computed/speedline-test.js +++ b/lighthouse-core/test/gather/computed/speedline-test.js @@ -34,14 +34,14 @@ describe('Speedline gatherer', () => { assert.equal(speedline.speedIndex, undefined); assert.equal(Math.floor(speedline.perceptualSpeedIndex), 609); }); - }); + }).timeout(10000); it('measures SI of 3 frame trace (blank @1s, content @2s, more content @3s)', () => { return computedArtifacts.requestSpeedline(threeFrameTrace).then(speedline => { assert.equal(speedline.speedIndex, undefined); assert.equal(Math.floor(speedline.perceptualSpeedIndex), 2030); }); - }); + }).timeout(10000); it('uses a cache', () => { let start; @@ -62,7 +62,7 @@ describe('Speedline gatherer', () => { return assert.equal(Math.floor(speedline.perceptualSpeedIndex), 609); }); - }); + }).timeout(10000); it('does not change order of events in traces', () => { // Use fresh trace in case it has been altered by other require()s. @@ -78,5 +78,5 @@ describe('Speedline gatherer', () => { assert.deepStrictEqual(pwaTrace[i], freshTrace[i]); } }); - }); + }).timeout(10000); }); diff --git a/lighthouse-core/test/lib/asset-saver-test.js b/lighthouse-core/test/lib/asset-saver-test.js index c73f941d41..4f49dc5af0 100644 --- a/lighthouse-core/test/lib/asset-saver-test.js +++ b/lighthouse-core/test/lib/asset-saver-test.js @@ -124,7 +124,7 @@ describe('asset-saver helper', () => { const traceEventsFromDisk = JSON.parse(traceFileContents).traceEvents; assertTraceEventsEqual(traceEventsFromDisk, fullTraceObj.traceEvents); }); - }); + }).timeout(10000); it('correctly saves a trace with no trace events to disk', () => { const trace = { @@ -186,6 +186,6 @@ describe('asset-saver helper', () => { const fileStats = fs.lstatSync(traceFilename); assert.ok(fileStats.size > Math.pow(2, 28)); }); - }); + }).timeout(40 * 1000); }); }); diff --git a/lighthouse-core/test/lib/traces/trace-parser-test.js b/lighthouse-core/test/lib/traces/trace-parser-test.js index 3152123f65..1f2d2f05e7 100644 --- a/lighthouse-core/test/lib/traces/trace-parser-test.js +++ b/lighthouse-core/test/lib/traces/trace-parser-test.js @@ -35,7 +35,7 @@ describe('traceParser parser', () => { done(); }); - }); + }).timeout(10000); it('parses a trace > 256mb (slow)', () => { @@ -89,5 +89,5 @@ describe('traceParser parser', () => { assert.deepStrictEqual( streamedTrace.traceEvents[events.length - 2], events[0]); - }); + }).timeout(40 * 1000); });