aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/turbo-test-utils/src/spyExit.ts
blob: 1df9844b8f3aeab21f86601cda056c5cdad3e913 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export type SpyExit = { exit?: any };

export default function spyExit() {
  let spy: SpyExit = {};

  beforeEach(() => {
    spy.exit = jest
      .spyOn(process, "exit")
      .mockImplementation(() => undefined as never);
  });

  afterEach(() => {
    spy.exit.mockClear();
  });

  afterAll(() => {
    spy.exit.mockRestore();
  });

  return spy;
}