From 55d34f8707fd7e6394434fa89be20bf335b3b685 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 1 Dec 2022 01:37:09 +0000 Subject: [PATCH] Fixes incorrect validation of time values in JUnit Reporter (#2965) Signed-off-by: Miki Signed-off-by: Miki (cherry picked from commit a56480b1c2a12ddc4a9d6947270152a789b10217) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md --- src/dev/jest/junit_reporter.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dev/jest/junit_reporter.js b/src/dev/jest/junit_reporter.js index 082d9bc9a1b0..49bd0241a03f 100644 --- a/src/dev/jest/junit_reporter.js +++ b/src/dev/jest/junit_reporter.js @@ -72,8 +72,9 @@ export default class JestJUnitReporter { { skipNullAttributes: true } ); - const msToIso = (ms) => (ms ? new Date(ms).toISOString().slice(0, -5) : undefined); - const msToSec = (ms) => (ms ? (ms / 1000).toFixed(3) : undefined); + const isNumeric = (val) => !isNaN(parseFloat(val)) && isFinite(val); + const msToIso = (ms) => (isNumeric(ms) ? new Date(ms).toISOString().slice(0, -5) : undefined); + const msToSec = (ms) => (isNumeric(ms) ? (ms / 1000).toFixed(3) : undefined); root.att({ name: 'jest',