diff --git a/packages/react/src/components/DetailsList/DetailsList.test.tsx b/packages/react/src/components/DetailsList/DetailsList.test.tsx index d2e40b859ee35f..0daf2b79faf2c7 100644 --- a/packages/react/src/components/DetailsList/DetailsList.test.tsx +++ b/packages/react/src/components/DetailsList/DetailsList.test.tsx @@ -68,19 +68,16 @@ function customColumnDivider( describe('DetailsList', () => { let spy: jest.SpyInstance; - beforeAll(() => { + beforeEach(() => { /* eslint-disable-next-line @typescript-eslint/no-empty-function */ spy = jest.spyOn(window, 'scrollTo').mockImplementation(() => {}); + resetIds(); }); afterAll(() => { spy.mockRestore(); }); - beforeEach(() => { - resetIds(); - }); - afterEach(() => { if ((setTimeout as unknown as jest.Mock).mock) { jest.runOnlyPendingTimers(); diff --git a/packages/react/src/components/DetailsList/DetailsListV2.test.tsx b/packages/react/src/components/DetailsList/DetailsListV2.test.tsx index da424735418675..9766f957b55d8b 100644 --- a/packages/react/src/components/DetailsList/DetailsListV2.test.tsx +++ b/packages/react/src/components/DetailsList/DetailsListV2.test.tsx @@ -77,7 +77,8 @@ const groupProps: IDetailsGroupRenderProps = { */ describe('DetailsListV2', () => { let spy: jest.SpyInstance; - beforeAll(() => { + + beforeEach(() => { /* eslint-disable-next-line @typescript-eslint/no-empty-function */ spy = jest.spyOn(window, 'scrollTo').mockImplementation(() => {}); }); diff --git a/packages/react/src/components/Dialog/Dialog.deprecated.test.tsx b/packages/react/src/components/Dialog/Dialog.deprecated.test.tsx index 57c18ad1942dbf..c6ac7dc65bfc3a 100644 --- a/packages/react/src/components/Dialog/Dialog.deprecated.test.tsx +++ b/packages/react/src/components/Dialog/Dialog.deprecated.test.tsx @@ -6,24 +6,24 @@ import { resetIds, setWarningCallback } from '../../Utilities'; import { DialogBase } from './Dialog.base'; describe('Dialog deprecated props', () => { - beforeEach(() => { - resetIds(); + beforeAll(() => { + // eslint-disable-next-line @typescript-eslint/no-empty-function + const noop = () => {}; + // Prevent warn deprecations from failing test + setWarningCallback(noop); }); - afterAll(() => { + beforeEach(() => { resetIds(); - }); - - beforeAll(() => { - // Prevent warn deprecations from failing test - setWarningCallback(() => { - /* no-op */ - }); (ReactDOM.createPortal as any) = jest.fn((element, node) => { return element; }); }); + afterAll(() => { + setWarningCallback(); + }); + afterEach(() => { (ReactDOM.createPortal as any).mockClear(); jest.useRealTimers(); diff --git a/packages/react/src/components/Dialog/Dialog.test.tsx b/packages/react/src/components/Dialog/Dialog.test.tsx index 1d5b969ac78d7f..83186263f8f3ac 100644 --- a/packages/react/src/components/Dialog/Dialog.test.tsx +++ b/packages/react/src/components/Dialog/Dialog.test.tsx @@ -14,11 +14,6 @@ describe('Dialog', () => { resetIds(); }); - afterEach(() => { - setWarningCallback(); - jest.useRealTimers(); - }); - afterAll(() => { resetIds(); }); @@ -86,11 +81,14 @@ describe('Dialog', () => { expect(queryByRole('dialog')).toBeFalsy(); expect(onDismissed).toHaveBeenCalledTimes(1); + + jest.useRealTimers(); }); it('deprecated isOpen controls open state of the dialog', () => { // suppress deprecation warning as error - setWarningCallback(() => undefined); + // eslint-disable-next-line @typescript-eslint/no-empty-function + setWarningCallback(() => {}); jest.useFakeTimers(); const onDismissed = jest.fn(); @@ -106,6 +104,9 @@ describe('Dialog', () => { expect(queryByRole('dialog')).toBeFalsy(); expect(onDismissed).toHaveBeenCalledTimes(1); + + jest.useRealTimers(); + setWarningCallback(); }); it('Properly attaches auto-generated aria attributes IDs', () => { @@ -154,7 +155,7 @@ describe('Dialog', () => {