diff --git a/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js b/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js index 15a87f147cd7..add58f38a1aa 100644 --- a/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js +++ b/lighthouse-core/test/audits/byte-efficiency/uses-long-cache-ttl-test.js @@ -30,6 +30,18 @@ function networkRecord(options = {}) { } describe('Cache headers audit', () => { + // Stub Date.now so the tests are not sensitive to timing. + let dateNowFn; + beforeAll(() => { + dateNowFn = Date.now; + const now = Date.now(); + Date.now = () => now; + }); + + afterAll(() => { + Date.now = dateNowFn; + }); + function getArtifacts(networkRecords) { const devtoolLogs = networkRecordsToDevtoolsLog(networkRecords);