From 0bb9868c4c9ef32725f65283768bddec3a033907 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 30 Nov 2022 19:43:18 -0800 Subject: [PATCH] Fixes incorrect validation of time values in JUnit Reporter (#2965) (#2982) 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',