From 08bb298b9b0d88c35a14595f1d891c11eeca0386 Mon Sep 17 00:00:00 2001 From: Baptiste HAUDEGAND Date: Fri, 2 Oct 2020 14:40:50 +0200 Subject: [PATCH] Debug timeToFirstByte unit test --- test/spec/modules/teadsBidAdapter_spec.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 17841b271d4..d106258518c 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -211,9 +211,15 @@ describe('teadsBidAdapter', () => { if (ttfbExpectedV2) { expect(payload.timeToFirstByte).to.deep.equal(ttfbExpectedV2.toString()); } else { - const ttfbExpectedV1 = performance.timing.responseStart - performance.timing.requestStart; - - expect(payload.timeToFirstByte).to.deep.equal(ttfbExpectedV1.toString()); + const ttfbWithTimingV1 = performance && + performance.timing.responseStart && + performance.timing.requestStart && + performance.timing.responseStart >= 0 && + performance.timing.requestStart >= 0 && + performance.timing.responseStart - performance.timing.requestStart; + const ttfbExpectedV1 = ttfbWithTimingV1 ? ttfbWithTimingV1.toString() : ''; + + expect(payload.timeToFirstByte).to.deep.equal(ttfbExpectedV1); } });