import { render } from '../../helpers/testUtils';
import { DateRangePicker } from '../DateRangePicker';
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers().setSystemTime(parseISO('2022-06-12'));
});
-afterAll(() => {
+afterEach(() => {
+ jest.runOnlyPendingTimers();
jest.useRealTimers();
});
import { render, screen } from '@testing-library/react';
import { DeferredSpinner } from '../DeferredSpinner';
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.runOnlyPendingTimers();
-});
-
-afterAll(() => {
jest.useRealTimers();
});
const elements = ['foo', 'bar', 'baz'];
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers();
});
-afterAll(() => {
+afterEach(() => {
+ jest.runOnlyPendingTimers();
jest.useRealTimers();
});
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { render as rtlRender, RenderOptions } from '@testing-library/react';
+import { RenderOptions, render as rtlRender } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Options as UserEventsOptions } from '@testing-library/user-event/dist/types/options';
import { InitialEntry } from 'history';
return debounced;
});
-
-export function flushPromises(usingFakeTime = false): Promise<void> {
- return new Promise((resolve) => {
- if (usingFakeTime) {
- jest.useRealTimers();
- }
- setTimeout(resolve, 0);
- if (usingFakeTime) {
- jest.useFakeTimers();
- }
- });
-}
getWebAnalyticsPageHandlerFromCache: jest.fn().mockReturnValue(undefined),
}));
-beforeAll(() => {
+beforeEach(() => {
+ jest.clearAllMocks();
jest.useFakeTimers();
});
-afterAll(() => {
+afterEach(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
-beforeEach(() => {
- jest.clearAllTimers();
- jest.clearAllMocks();
-});
-
it('should not trigger if no analytics system is given', () => {
const wrapper = shallowRender();
expect(wrapper).toMatchSnapshot();
const replace = jest.fn();
beforeAll(() => {
- jest.useFakeTimers();
-
const location = {
...window.location,
replace,
});
afterAll(() => {
- jest.runOnlyPendingTimers();
- jest.useRealTimers();
-
Object.defineProperty(window, 'location', {
writable: true,
value: originalLocation,
});
});
-beforeEach(jest.clearAllMocks);
+beforeEach(() => {
+ jest.clearAllMocks();
+ jest.useFakeTimers();
+});
+
+afterEach(() => {
+ jest.runOnlyPendingTimers();
+ jest.useRealTimers();
+});
describe('Maintenance', () => {
it.each([
getPullRequestRow: () => within(ui.pullRequestTabContent.get()).getAllByRole('row'),
};
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers({
advanceTimers: true,
now: new Date('2018-02-01T07:08:59Z'),
});
-});
-
-beforeEach(() => {
handler.reset();
settingsHandler.reset();
});
+afterEach(() => {
+ jest.runOnlyPendingTimers();
+ jest.useRealTimers();
+});
+
it('should show all branches', async () => {
renderProjectBranchesApp();
expect(await ui.branchTabContent.find()).toBeInTheDocument();
noDumpImportMsg: byText('project_dump.no_file_to_import'),
};
-afterAll(() => {
- jest.useRealTimers();
-});
-
beforeEach(() => {
computeEngineHandler.reset();
handler.reset();
});
});
+afterEach(() => {
+ jest.runOnlyPendingTimers();
+ jest.useRealTimers();
+});
+
it('can export project, but can not import', async () => {
renderProjectKeyApp([Feature.ProjectImport]);
expect(await ui.exportBtn.find()).toBeInTheDocument();
}),
};
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers({
advanceTimers: true,
now: new Date('2019-01-05T07:08:59Z'),
});
afterEach(() => {
+ jest.runOnlyPendingTimers();
+ jest.useRealTimers();
+
permissionsHandler.reset();
settingsHandler.reset();
handler.reset();
describe('Github Provisioning', () => {
let user: UserEvent;
+
beforeEach(() => {
jest.useFakeTimers({
advanceTimers: true,
});
user = userEvent.setup();
});
+
+ afterEach(() => {
+ jest.runOnlyPendingTimers();
+ jest.useRealTimers();
+ });
+
it('should display a success status when the synchronisation is a success', async () => {
handler.addProvisioningTask({
status: TaskStatuses.Success,
});
describe('different filters combinations', () => {
- beforeAll(() => {
+ beforeEach(() => {
jest.useFakeTimers({
advanceTimers: true,
now: new Date('2023-07-05T07:08:59Z'),
});
});
- afterAll(() => {
+ afterEach(() => {
+ jest.runOnlyPendingTimers();
jest.useRealTimers();
});
import { byRole } from '../../../helpers/testSelector';
import Toggler from '../Toggler';
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers();
});
-afterAll(() => {
+afterEach(() => {
+ jest.runOnlyPendingTimers();
jest.useRealTimers();
});
const ui = {
import * as React from 'react';
import Tooltip, { TooltipInner, TooltipProps } from '../Tooltip';
-beforeAll(() => {
+beforeEach(() => {
+ jest.clearAllMocks();
jest.useFakeTimers();
});
-afterAll(() => {
+afterEach(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
});
});
-beforeEach(jest.clearAllMocks);
-
it('should render', () => {
expect(shallowRenderTooltipInner()).toMatchSnapshot();
expect(
ClipboardIconButtonProps,
} from '../clipboard';
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers();
});
-afterAll(() => {
+afterEach(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
import * as React from 'react';
import DeferredSpinner from '../DeferredSpinner';
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.runOnlyPendingTimers();
-});
-
-afterAll(() => {
jest.useRealTimers();
});
import * as React from 'react';
import WorkspaceRuleViewer, { Props } from '../WorkspaceRuleViewer';
-beforeAll(() => {
+beforeEach(() => {
jest.useFakeTimers();
});
-afterAll(() => {
+afterEach(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
addGlobalErrorMessage: jest.fn(),
}));
-beforeAll(() => {
- jest.useFakeTimers();
-});
-
beforeEach(() => {
+ jest.useFakeTimers();
jest.clearAllMocks();
});
-afterAll(() => {
+afterEach(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
});
describe('requestTryAndRepeatUntil', () => {
- beforeAll(() => {
+ beforeEach(() => {
+ jest.clearAllTimers();
jest.useFakeTimers();
});
- afterAll(() => {
+ afterEach(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
- beforeEach(() => {
- jest.clearAllTimers();
- });
-
it('should repeat call until stop condition is met', async () => {
const apiCall = jest.fn().mockResolvedValue({ repeat: true });
const stopRepeat = jest.fn().mockImplementation(({ repeat }) => !repeat);