From 009081ece62778978b2c0766b246399a6b587933 Mon Sep 17 00:00:00 2001 From: mizdra Date: Wed, 29 Dec 2021 00:25:02 +0900 Subject: [PATCH] fix: don't use `jest.requireActual` --- test/formatter/index.test.ts | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/test/formatter/index.test.ts b/test/formatter/index.test.ts index 5b2bedf4..b72f9ea0 100644 --- a/test/formatter/index.test.ts +++ b/test/formatter/index.test.ts @@ -1,24 +1,7 @@ -const mockFormatByFiles = jest.fn(() => 'formatByFiles'); -const mockFormatByRules = jest.fn(() => 'formatByRules'); - -import { jest } from '@jest/globals'; import { ESLint } from 'eslint'; import { format } from '../../src/formatter/index.js'; import { fakeLintResult, fakeLintMessage } from '../test-util/eslint.js'; -jest.mock('../../src/formatter/format-by-files', () => { - return { - ...jest.requireActual('../../src/formatter/format-by-files'), - formatByFiles: mockFormatByFiles, - }; -}); -jest.mock('../../src/formatter/format-by-rules', () => { - return { - ...jest.requireActual('../../src/formatter/format-by-rules'), - formatByRules: mockFormatByRules, - }; -}); - describe('format', () => { test('call `formatByFiles` and `formatByRules`', () => { const results: ESLint.LintResult[] = [ @@ -29,10 +12,13 @@ describe('format', () => { const data: ESLint.LintResultData = { rulesMeta: {} }; const formattedText = format(results, data); expect(formattedText).toMatchInlineSnapshot(` -"formatByFiles -formatByRules" -`); - expect(mockFormatByFiles).toBeCalledWith(results); - expect(mockFormatByRules).toBeCalledWith(results, data); + "- 1 file (0 file passed, 1 file failed) checked. +  + ┌────────┬───────┬─────────┬────────────┬─────────────────┐ + │ Rule │ Error │ Warning │ is fixable │ has suggestions │ + ├────────┼───────┼─────────┼────────────┼─────────────────┤ + │ rule-a │ 1 │ 0 │ 0 │ 0 │ + └────────┴───────┴─────────┴────────────┴─────────────────┘" + `); }); });