Merge pull request #18794 from strapi/chore/flaky-tests

This commit is contained in:
Alexandre BODIN 2023-11-16 09:42:56 +01:00 committed by GitHub
commit 50ae047484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 10 deletions

View File

@ -131,7 +131,7 @@ jobs:
- name: Monorepo build
uses: ./.github/actions/run-build
- name: Run test
run: yarn nx affected --target=test:front --nx-ignore-cycles
run: yarn nx affected --target=test:front --nx-ignore-cycles -- --runInBand
e2e:
timeout-minutes: 60

View File

@ -2,7 +2,7 @@ import React from 'react';
import { lightTheme, ThemeProvider } from '@strapi/design-system';
import { NotificationsProvider } from '@strapi/helper-plugin';
import { render as renderRTL, waitFor } from '@testing-library/react';
import { render as renderRTL, waitFor, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
@ -106,13 +106,15 @@ describe('InputUID', () => {
labelAction: <>action</>,
});
await waitFor(() => expect(getByText('Unavailable')).toBeInTheDocument());
await waitFor(() => {
expect(getByText('Unavailable')).toBeInTheDocument();
expect(getByText('Label')).toBeInTheDocument();
expect(getByText('*')).toBeInTheDocument();
expect(getByText('action')).toBeInTheDocument();
expect(getByText('hint')).toBeInTheDocument();
expect(getByRole('textbox')).toHaveValue('test');
expect(getByText('Label')).toBeInTheDocument();
expect(getByText('*')).toBeInTheDocument();
expect(getByText('action')).toBeInTheDocument();
expect(getByText('hint')).toBeInTheDocument();
expect(getByRole('textbox')).toHaveValue('test');
});
});
test('renders an error', async () => {
@ -200,6 +202,7 @@ describe('InputUID', () => {
});
test('Checks the initial availability (isAvailable)', async () => {
jest.useFakeTimers();
const spy = jest.fn();
const { getByText, queryByText, queryByTestId } = render({
@ -212,9 +215,16 @@ describe('InputUID', () => {
expect(getByText('Available')).toBeInTheDocument();
act(() => {
jest.advanceTimersByTime(4000);
});
await waitFor(() => expect(queryByText('Available')).not.toBeInTheDocument(), {
timeout: 10000,
});
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
test('Checks the initial availability (!isAvailable)', async () => {

View File

@ -11,6 +11,6 @@
"build": "pack-up build && pack-up check"
},
"dependencies": {
"@strapi/pack-up": "../../../"
"@strapi/pack-up": "file:../../../"
}
}

View File

@ -11,6 +11,6 @@
"build": "pack-up build && pack-up check"
},
"dependencies": {
"@strapi/pack-up": "../../../"
"@strapi/pack-up": "file:../../../"
}
}