diff --git a/packages/jest-core/src/lib/__tests__/serializeToJSON.test.ts b/packages/jest-core/src/lib/__tests__/serializeToJSON.test.ts index f20a796fcb37..220401524310 100644 --- a/packages/jest-core/src/lib/__tests__/serializeToJSON.test.ts +++ b/packages/jest-core/src/lib/__tests__/serializeToJSON.test.ts @@ -9,17 +9,17 @@ import serializeToJSON from '../serializeToJSON'; // populate an object with all basic JavaScript datatypes const object = { - species: 'capybara', - ok: true, - i: ['pull up'], + chillness: 100, + flaws: null, hopOut: { atThe: 'after party', when: new Date('2000-07-14'), }, - chillness: 100, - weight: 9.5, - flaws: null, + i: ['pull up'], location: undefined, + ok: true, + species: 'capybara', + weight: 9.5, }; it('serializes regular objects like JSON.stringify', () => { @@ -36,9 +36,9 @@ it('serializes errors', () => { expect(withoutError).not.toEqual(withError); - expect(withError).toContain(`"message":"too cool"`); - expect(withError).toContain(`"name":"Error"`); - expect(withError).toContain(`"stack":"Error:`); + expect(withError).toContain('"message":"too cool"'); + expect(withError).toContain('"name":"Error"'); + expect(withError).toContain('"stack":"Error:'); expect(JSON.parse(withError)).toMatchObject({ error: { diff --git a/packages/jest-core/src/lib/serializeToJSON.ts b/packages/jest-core/src/lib/serializeToJSON.ts index 1228329848b0..ce9798dc4cc1 100644 --- a/packages/jest-core/src/lib/serializeToJSON.ts +++ b/packages/jest-core/src/lib/serializeToJSON.ts @@ -13,7 +13,7 @@ * This function handles the extended serialization wanted above. */ export default function serializeToJSON( - value: any, + value: unknown, space?: string | number, ): string { return JSON.stringify( diff --git a/packages/jest-core/src/runJest.ts b/packages/jest-core/src/runJest.ts index 29f975e10ec9..fe73415807d2 100644 --- a/packages/jest-core/src/runJest.ts +++ b/packages/jest-core/src/runJest.ts @@ -33,9 +33,9 @@ import collectNodeHandles, { type HandleCollectionResult, } from './collectHandles'; import getNoTestsFoundMessage from './getNoTestsFoundMessage'; +import serializeToJSON from './lib/serializeToJSON'; import runGlobalHook from './runGlobalHook'; import type {Filter, TestRunData} from './types'; -import serializeToJSON from './lib/serializeToJSON'; const getTestPaths = async ( globalConfig: Config.GlobalConfig, @@ -117,17 +117,12 @@ const processResults = async ( const cwd = tryRealpath(process.cwd()); const filePath = path.resolve(cwd, outputFile); - fs.writeFileSync( - filePath, - `${jsonString}\n`, - ); + fs.writeFileSync(filePath, `${jsonString}\n`); outputStream.write( `Test results written to: ${path.relative(cwd, filePath)}\n`, ); } else { - process.stdout.write( - `${jsonString}\n`, - ); + process.stdout.write(`${jsonString}\n`); } }