From 16aafdc05dcb920c6d8f463c3316e55ccfbee67b Mon Sep 17 00:00:00 2001 From: Allison Kemmerle Date: Fri, 17 Jan 2025 13:45:34 -0500 Subject: [PATCH] Address feedback p2 --- lib/projects/__tests__/projects.test.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/projects/__tests__/projects.test.ts b/lib/projects/__tests__/projects.test.ts index 9cc835553..cb9afae48 100644 --- a/lib/projects/__tests__/projects.test.ts +++ b/lib/projects/__tests__/projects.test.ts @@ -9,29 +9,22 @@ jest.mock('@hubspot/local-dev-lib/logger'); describe('lib/projects', () => { describe('validateProjectConfig()', () => { - let realProcess: NodeJS.Process; let projectDir: string; - let exitMock: jest.Mock; + let exitMock: jest.SpyInstance; beforeAll(() => { projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'projects-')); fs.mkdirSync(path.join(projectDir, 'src')); - - realProcess = process; }); beforeEach(() => { - exitMock = jest.fn(); - global.process = { - ...realProcess, - exit: exitMock as unknown as ( - code?: number | string | null | undefined - ) => never, - }; + exitMock = jest.spyOn(process, 'exit').mockImplementation((): never => { + throw new Error('process.exit() was called.'); + }); }); afterAll(() => { - global.process = realProcess; + exitMock.mockRestore(); }); it('rejects undefined configuration', () => {