fix flaky test 'produces a valid junit report for failures' (#143995)

* fix flaky test 'produces a valid junit report for failures'

After the upgrading to Jest 27, it appears the runtime of this test is
occasionally reported as 0.  0 is evaluated to false and time is left
out of the junit report.  This updates the conditional to check for type
number.

Closes #143993

* unskip
This commit is contained in:
Jonathan Budzenski 2022-10-26 10:49:00 -05:00 committed by GitHub
parent cf8e6a7eaa
commit 7a056a84d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -26,8 +26,7 @@ afterAll(async () => {
});
const parseXml = promisify(xml2js.parseString);
// FLAKY https://github.com/elastic/kibana/issues/143993
it.skip(
it(
'produces a valid junit report for failures',
async () => {
const result = await execa(

View file

@ -60,8 +60,9 @@ export default class JestJUnitReporter extends BaseReporter {
);
const msToIso = (ms: number | null | undefined) =>
ms ? new Date(ms).toISOString().slice(0, -5) : undefined;
const msToSec = (ms: number | null | undefined) => (ms ? (ms / 1000).toFixed(3) : undefined);
typeof ms === 'number' ? new Date(ms).toISOString().slice(0, -5) : undefined;
const msToSec = (ms: number | null | undefined) =>
typeof ms === 'number' ? (ms / 1000).toFixed(3) : undefined;
root.att({
name: 'jest',