From 2627a879f1803c70e89570bd74db7a7455e036bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Chalk?= Date: Tue, 25 Jun 2024 17:28:55 +0200 Subject: [PATCH] feat(plugin-lighthouse): keep audit values as floats --- packages/plugin-lighthouse/src/lib/runner/utils.ts | 2 +- packages/plugin-lighthouse/src/lib/runner/utils.unit.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-lighthouse/src/lib/runner/utils.ts b/packages/plugin-lighthouse/src/lib/runner/utils.ts index 85d29cd95..58cee1a4a 100644 --- a/packages/plugin-lighthouse/src/lib/runner/utils.ts +++ b/packages/plugin-lighthouse/src/lib/runner/utils.ts @@ -50,7 +50,7 @@ export function toAuditOutputs( const auditOutput: AuditOutput = { slug, score: score ?? 1, // score can be null - value: Number.parseInt(value.toString(), 10), + value, displayValue, }; diff --git a/packages/plugin-lighthouse/src/lib/runner/utils.unit.test.ts b/packages/plugin-lighthouse/src/lib/runner/utils.unit.test.ts index 06de390a1..3871ace1f 100644 --- a/packages/plugin-lighthouse/src/lib/runner/utils.unit.test.ts +++ b/packages/plugin-lighthouse/src/lib/runner/utils.unit.test.ts @@ -91,7 +91,7 @@ describe('toAuditOutputs', () => { ).not.toThrow(); }); - it('should parse valid lhr float value to integer', () => { + it('should copy lhr numericValue to audit value as float', () => { expect( toAuditOutputs([ { @@ -106,7 +106,7 @@ describe('toAuditOutputs', () => { displayValue: '2.8 s', }, ]), - ).toStrictEqual([expect.objectContaining({ value: 2838 })]); + ).toStrictEqual([expect.objectContaining({ value: 2838.974 })]); }); it('should convert null score to 1', () => {