Fix flaky Cypress test (#6415)

* Fix flaky Cypress test

* Add jest fake timers
This commit is contained in:
Vivek Ratnavel Subramanian 2022-07-28 21:19:22 -07:00 committed by GitHub
parent ea918495ff
commit fe7151e870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 1 deletions

View File

@ -197,7 +197,6 @@ export const deleteCreatedService = (typeOfService, service_Name) => {
.type('DELETE');
cy.get('[data-testid="confirm-button"]').should('be.visible').click();
cy.wait(2000);
cy.get('.tw-modal-container').should('not.exist');
cy.get('[class="Toastify__toast-body"] >div')
.eq(1)
.should('exist')

View File

@ -56,4 +56,7 @@ module.exports = {
// Sonar Cloud Configuration
testResultsProcessor: 'jest-sonar-reporter',
// use fake timers
timers: 'fake',
};

View File

@ -23,6 +23,8 @@ import PopOver from './PopOver';
let global;
jest.useRealTimers();
global.document.createRange = () => ({
setStart: jest.fn(),
setEnd: jest.fn(),

View File

@ -15,6 +15,8 @@ import { fireEvent, getByTestId, render } from '@testing-library/react';
import React from 'react';
import Searchbar from './Searchbar';
jest.useRealTimers();
describe('Test Searchbar Component', () => {
it('Renders the searchbar with the search text sent to it', () => {
const onSearch = jest.fn();

View File

@ -57,6 +57,8 @@ const mockUseHistory = {
push: jest.fn(),
};
jest.useRealTimers();
jest.mock('../../AppState', () => ({
userDetails: {
name: 'test',

View File

@ -21,6 +21,8 @@ import {
import { MOCK_GLOSSARY } from './glossary.mock';
import GlossaryPageV1 from './GlossaryPageV1.component';
jest.useRealTimers();
jest.mock('react-router-dom', () => ({
useHistory: () => ({
push: jest.fn(),

View File

@ -43,6 +43,8 @@ const MOCK_HISTORY = {
push: jest.fn(),
};
jest.useRealTimers();
jest.mock('../../components/containers/PageContainerV1', () => {
return jest
.fn()

View File

@ -30,6 +30,8 @@ import {
} from '../../axiosAPIs/tagAPI';
import { getTagCategories } from '../../utils/TagsUtils';
jest.useRealTimers();
jest.mock('../../authentication/auth-provider/AuthProvider', () => {
return {
useAuthContext: jest.fn(() => ({