From 1fef624c316d423f147a92c5e15ff4a08da0281f Mon Sep 17 00:00:00 2001 From: LekoArts Date: Wed, 1 Feb 2023 16:13:40 +0100 Subject: [PATCH] chore: Fix construct-error tests --- .../__tests__/construct-error.ts | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/gatsby-cli/src/structured-errors/__tests__/construct-error.ts b/packages/gatsby-cli/src/structured-errors/__tests__/construct-error.ts index 7567c1523b6e0..be2f8e0348c14 100644 --- a/packages/gatsby-cli/src/structured-errors/__tests__/construct-error.ts +++ b/packages/gatsby-cli/src/structured-errors/__tests__/construct-error.ts @@ -2,21 +2,16 @@ import constructError from "../construct-error" import { errorMap } from "../error-map" import { Level } from "../types" -let log -let processExit -beforeEach(() => { - log = jest.spyOn(console, `log`).mockImplementation(() => {}) - processExit = ( - jest.spyOn(process, `exit`) as unknown as jest.Mock - ).mockImplementation(() => {}) +const processExit = ( + jest.spyOn(process, `exit`) as unknown as jest.Mock +).mockImplementation(() => {}) +const log = ( + jest.spyOn(console, `log`) as unknown as jest.Mock +).mockImplementation(() => {}) - log.mockReset() - processExit.mockReset() -}) - -afterAll(() => { - ;(console.log as jest.Mock).mockClear() - ;(process.exit as unknown as jest.Mock).mockClear() +afterEach(() => { + log.mockClear() + processExit.mockClear() }) test(`it exits on invalid error schema`, () => {