From 1675b918783e7a42c95d819768798470c43bf21a Mon Sep 17 00:00:00 2001 From: Miki Date: Wed, 30 Nov 2022 17:35:09 -0800 Subject: [PATCH] Fixes incorrect validation of time values in JUnit Reporter (#2965) Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: Sergey Osipov --- CHANGELOG.md | 1 + src/dev/jest/junit_reporter.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d52c38207e..e07be8cb2b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [Multi DataSource] Add unit test coverage for Update Data source management stack ([#2567](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2567)) - [BWC Tests] Add BWC tests for 2.5.0 ([#2890](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2890)) +- Fix incorrect validation of time values in JUnit Reporter ([#2965](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2965)) ## [2.x] diff --git a/src/dev/jest/junit_reporter.js b/src/dev/jest/junit_reporter.js index 35b8a5a3960..65f244042a1 100644 --- a/src/dev/jest/junit_reporter.js +++ b/src/dev/jest/junit_reporter.js @@ -70,8 +70,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',