From e6d3dce424bf9c5896569368e95834fbef90a7ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Wed, 23 Oct 2024 22:34:46 +0200 Subject: [PATCH] chore: add retry to flaky tests (#4175) --- .../forms/Field/PhoneNumber/__tests__/PhoneNumber.test.tsx | 5 +++++ .../forms/Form/Isolation/__tests__/Isolation.test.tsx | 5 +++++ .../SubmitConfirmation/__tests__/SubmitConfirmation.test.tsx | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/packages/dnb-eufemia/src/extensions/forms/Field/PhoneNumber/__tests__/PhoneNumber.test.tsx b/packages/dnb-eufemia/src/extensions/forms/Field/PhoneNumber/__tests__/PhoneNumber.test.tsx index 3d5969c85ac..a3ddb025a9f 100644 --- a/packages/dnb-eufemia/src/extensions/forms/Field/PhoneNumber/__tests__/PhoneNumber.test.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/Field/PhoneNumber/__tests__/PhoneNumber.test.tsx @@ -1,4 +1,5 @@ import React from 'react' +import { isCI } from 'repo-utils' import { wait, axeComponent } from '../../../../../core/jest/jestSetup' import { fireEvent, render, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' @@ -9,6 +10,10 @@ import locales from '../../../constants/locales' const nbNO = locales['nb-NO'] const enGB = locales['en-GB'] +if (isCI) { + jest.retryTimes(5) // because of an flaky async tests +} + describe('Field.PhoneNumber', () => { it('should default to 47', () => { render() diff --git a/packages/dnb-eufemia/src/extensions/forms/Form/Isolation/__tests__/Isolation.test.tsx b/packages/dnb-eufemia/src/extensions/forms/Form/Isolation/__tests__/Isolation.test.tsx index c9a9b8ca421..1977b8a86e6 100644 --- a/packages/dnb-eufemia/src/extensions/forms/Form/Isolation/__tests__/Isolation.test.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/Form/Isolation/__tests__/Isolation.test.tsx @@ -1,5 +1,6 @@ import React from 'react' import { spyOnEufemiaWarn } from '../../../../../core/jest/jestSetup' +import { isCI } from 'repo-utils' import { act, createEvent, @@ -14,6 +15,10 @@ import setData from '../../data-context/setData' import nbNO from '../../../constants/locales/nb-NO' const nb = nbNO['nb-NO'] +if (isCI) { + jest.retryTimes(5) // because of an flaky async tests +} + describe('Form.Isolation', () => { let log = null beforeEach(() => { diff --git a/packages/dnb-eufemia/src/extensions/forms/Form/SubmitConfirmation/__tests__/SubmitConfirmation.test.tsx b/packages/dnb-eufemia/src/extensions/forms/Form/SubmitConfirmation/__tests__/SubmitConfirmation.test.tsx index 4aa05854a85..bfd84f6bca0 100644 --- a/packages/dnb-eufemia/src/extensions/forms/Form/SubmitConfirmation/__tests__/SubmitConfirmation.test.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/Form/SubmitConfirmation/__tests__/SubmitConfirmation.test.tsx @@ -1,10 +1,15 @@ import React from 'react' import { act, fireEvent, render, waitFor } from '@testing-library/react' +import { isCI } from 'repo-utils' import { Form, Wizard } from '../../..' import { Button, Dialog } from '../../../../../components' import { ConfirmParams } from '../SubmitConfirmation' import userEvent from '@testing-library/user-event' +if (isCI) { + jest.retryTimes(5) // because of an flaky async tests +} + describe('Form.SubmitConfirmation', () => { describe('with preventSubmitWhen', () => { it('should keep pending state when confirmationState is "readyToBeSubmitted"', async () => {