Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jan 15, 2025
1 parent 24bd16d commit 59cf055
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
18 changes: 9 additions & 9 deletions packages/jest-core/src/lib/__tests__/serializeToJSON.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/lib/serializeToJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 3 additions & 8 deletions packages/jest-core/src/runJest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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`);
}
}

Expand Down

0 comments on commit 59cf055

Please sign in to comment.