From 2234bbec54fce78494cf680f20d83540b2b372e9 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 1 Dec 2022 11:40:27 -0800 Subject: [PATCH] Fixes incorrect validation of time values in JUnit Reporter (#2965) (#2981) Signed-off-by: Miki Signed-off-by: Miki (cherry picked from commit a56480b1c2a12ddc4a9d6947270152a789b10217) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] --- 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',