diff --git a/packages/jest-cli/src/__tests__/cli/args.test.ts b/packages/jest-cli/src/__tests__/cli/args.test.ts index 6a3808f704c0..55fe1255671d 100644 --- a/packages/jest-cli/src/__tests__/cli/args.test.ts +++ b/packages/jest-cli/src/__tests__/cli/args.test.ts @@ -101,12 +101,12 @@ describe('check', () => { describe('buildArgv', () => { it('should return only camelcased args ', () => { - // @ts-expect-error const mockProcessArgv = jest + // @ts-expect-error .spyOn(process.argv, 'slice') .mockImplementation(() => ['--clear-mocks']); - // @ts-expect-error - const actual = buildArgv(null); + + const actual = buildArgv(); expect(actual).not.toHaveProperty('clear-mocks'); expect(actual).toHaveProperty('clearMocks', true); mockProcessArgv.mockRestore(); diff --git a/packages/jest-config/src/__tests__/getMaxWorkers.test.ts b/packages/jest-config/src/__tests__/getMaxWorkers.test.ts index 9710ad4e87ae..be3b29c4a8b5 100644 --- a/packages/jest-config/src/__tests__/getMaxWorkers.test.ts +++ b/packages/jest-config/src/__tests__/getMaxWorkers.test.ts @@ -39,19 +39,16 @@ describe('getMaxWorkers', () => { describe('% based', () => { it('50% = 2 workers', () => { const argv = {maxWorkers: '50%'}; - // @ts-expect-error: need to fix the typing expect(getMaxWorkers(argv)).toBe(2); }); it('< 0 workers should become 1', () => { const argv = {maxWorkers: '1%'}; - // @ts-expect-error: need to fix the typing expect(getMaxWorkers(argv)).toBe(1); }); it("0% shouldn't break", () => { const argv = {maxWorkers: '0%'}; - // @ts-expect-error: need to fix the typing expect(getMaxWorkers(argv)).toBe(1); }); }); diff --git a/packages/jest-config/src/__tests__/readConfigs.test.ts b/packages/jest-config/src/__tests__/readConfigs.test.ts index 25fc0e33c5a8..349b9180da51 100644 --- a/packages/jest-config/src/__tests__/readConfigs.test.ts +++ b/packages/jest-config/src/__tests__/readConfigs.test.ts @@ -29,7 +29,6 @@ test('readConfigs() loads async config file', async () => { rootDir: './', })); await expect( - // @ts-expect-error readConfigs( {} /* argv */, ['./some-jest-config-file.js'] /* projectPaths */, @@ -43,7 +42,6 @@ test('readConfigs() reject if async was rejected', async () => { throw new Error('Some error'); }); await expect( - // @ts-expect-error readConfigs( {} /* argv */, ['./some-jest-config-file.js'] /* projectPaths */, diff --git a/packages/jest-matcher-utils/src/__tests__/index.test.ts b/packages/jest-matcher-utils/src/__tests__/index.test.ts index 96412e07d461..f772aa6a8017 100644 --- a/packages/jest-matcher-utils/src/__tests__/index.test.ts +++ b/packages/jest-matcher-utils/src/__tests__/index.test.ts @@ -103,36 +103,32 @@ describe('stringify()', () => { }); describe('ensureNumbers()', () => { + const matcherName = 'toBeCloseTo'; + test('dont throw error when variables are numbers', () => { expect(() => { - // @ts-expect-error - ensureNumbers(1, 2); + ensureNumbers(1, 2, matcherName); }).not.toThrow(); if (isBigIntDefined) { expect(() => { - // @ts-expect-error - ensureNumbers(BigInt(1), BigInt(2)); + ensureNumbers(BigInt(1), BigInt(2), matcherName); }).not.toThrow(); } }); test('throws error when expected is not a number (backward compatibility)', () => { expect(() => { - // @ts-expect-error - ensureNumbers(1, 'not_a_number', '.toBeCloseTo'); + ensureNumbers(1, 'not_a_number', `.${matcherName}`); }).toThrowErrorMatchingSnapshot(); }); test('throws error when received is not a number (backward compatibility)', () => { expect(() => { - // @ts-expect-error - ensureNumbers('not_a_number', 3, '.toBeCloseTo'); + ensureNumbers('not_a_number', 3, `.${matcherName}`); }).toThrowErrorMatchingSnapshot(); }); describe('with options', () => { - const matcherName = 'toBeCloseTo'; - test('promise empty isNot false received', () => { const options: MatcherHintOptions = { isNot: false, @@ -140,7 +136,6 @@ describe('ensureNumbers()', () => { secondArgument: 'precision', }; expect(() => { - // @ts-expect-error ensureNumbers('', 0, matcherName, options); }).toThrowErrorMatchingSnapshot(); }); @@ -151,7 +146,6 @@ describe('ensureNumbers()', () => { // promise undefined is equivalent to empty string }; expect(() => { - // @ts-expect-error ensureNumbers(0.1, undefined, matcherName, options); }).toThrowErrorMatchingSnapshot(); }); @@ -162,7 +156,6 @@ describe('ensureNumbers()', () => { promise: 'rejects', }; expect(() => { - // @ts-expect-error ensureNumbers(0.01, '0', matcherName, options); }).toThrowErrorMatchingSnapshot(); }); @@ -173,7 +166,6 @@ describe('ensureNumbers()', () => { promise: 'rejects', }; expect(() => { - // @ts-expect-error ensureNumbers(Symbol('0.1'), 0, matcherName, options); }).toThrowErrorMatchingSnapshot(); }); @@ -184,7 +176,6 @@ describe('ensureNumbers()', () => { promise: 'resolves', }; expect(() => { - // @ts-expect-error ensureNumbers(false, 0, matcherName, options); }).toThrowErrorMatchingSnapshot(); }); @@ -195,7 +186,6 @@ describe('ensureNumbers()', () => { promise: 'resolves', }; expect(() => { - // @ts-expect-error ensureNumbers(0.1, null, matcherName, options); }).toThrowErrorMatchingSnapshot(); }); @@ -203,22 +193,23 @@ describe('ensureNumbers()', () => { }); describe('ensureNoExpected()', () => { + const matcherName = 'toBeDefined'; + test('dont throw error when undefined', () => { expect(() => { - // @ts-expect-error - ensureNoExpected(undefined); + ensureNoExpected(undefined, matcherName); }).not.toThrow(); }); test('throws error when expected is not undefined with matcherName', () => { expect(() => { - ensureNoExpected({a: 1}, '.toBeDefined'); + ensureNoExpected({a: 1}, `.${matcherName}`); }).toThrowErrorMatchingSnapshot(); }); test('throws error when expected is not undefined with matcherName and options', () => { expect(() => { - ensureNoExpected({a: 1}, 'toBeDefined', {isNot: true}); + ensureNoExpected({a: 1}, matcherName, {isNot: true}); }).toThrowErrorMatchingSnapshot(); }); }); diff --git a/packages/jest-serializer/src/__tests__/index.test.ts b/packages/jest-serializer/src/__tests__/index.test.ts index f97000d82623..61bea44cbb7a 100644 --- a/packages/jest-serializer/src/__tests__/index.test.ts +++ b/packages/jest-serializer/src/__tests__/index.test.ts @@ -19,8 +19,8 @@ const objs = [ {key1: 'foo', key2: 'bar', key3: {array: [null, {}]}}, {minusInf: -Infinity, nan: NaN, plusInf: +Infinity}, {date: new Date(1234567890), re: /foo/gi}, - // @ts-expect-error - testing NaN { + // @ts-expect-error - testing NaN map: new Map([ [NaN, 4], [undefined, 'm'], diff --git a/packages/jest-source-map/src/__tests__/getCallsite.test.ts b/packages/jest-source-map/src/__tests__/getCallsite.test.ts index 7ddf40b4a51b..fd36f705fb83 100644 --- a/packages/jest-source-map/src/__tests__/getCallsite.test.ts +++ b/packages/jest-source-map/src/__tests__/getCallsite.test.ts @@ -44,7 +44,7 @@ describe('getCallsite', () => { const sourceMapColumn = 1; const sourceMapLine = 2; - // @ts-expect-error + SourceMap.SourceMapConsumer = class { originalPositionFor(params: Record) { expect(params).toMatchObject({ diff --git a/packages/jest-test-result/src/__tests__/formatTestResults.test.ts b/packages/jest-test-result/src/__tests__/formatTestResults.test.ts index d186a02469ad..68936ddc25af 100644 --- a/packages/jest-test-result/src/__tests__/formatTestResults.test.ts +++ b/packages/jest-test-result/src/__tests__/formatTestResults.test.ts @@ -27,7 +27,7 @@ describe('formatTestResults', () => { }; it('includes test full name', () => { - const result = formatTestResults(results, null, null); + const result = formatTestResults(results, undefined, null); expect(result.testResults[0].assertionResults[0].fullName).toEqual( assertion.fullName, ); diff --git a/packages/pretty-format/src/__tests__/prettyFormat.test.ts b/packages/pretty-format/src/__tests__/prettyFormat.test.ts index b217830a1c5f..ce6652f19909 100644 --- a/packages/pretty-format/src/__tests__/prettyFormat.test.ts +++ b/packages/pretty-format/src/__tests__/prettyFormat.test.ts @@ -540,7 +540,6 @@ describe('prettyFormat()', () => { it('throws on invalid options', () => { expect(() => { - // @ts-expect-error prettyFormat({}, {invalidOption: true}); }).toThrow(); }); diff --git a/packages/pretty-format/src/__tests__/react.test.tsx b/packages/pretty-format/src/__tests__/react.test.tsx index e2cdad9c9a10..6cda12c16715 100644 --- a/packages/pretty-format/src/__tests__/react.test.tsx +++ b/packages/pretty-format/src/__tests__/react.test.tsx @@ -635,10 +635,7 @@ test('throws if theme option is null', () => { ); expect(() => { // @ts-expect-error - formatElement(jsx, { - highlight: true, - theme: null, - }); + formatElement(jsx, {highlight: true, theme: null}); }).toThrow('pretty-format: Option "theme" must not be null.'); }); @@ -650,10 +647,7 @@ test('throws if theme option is not of type "object"', () => { 'Hello, Mouse!', ); // @ts-expect-error - formatElement(jsx, { - highlight: true, - theme: 'beautiful', - }); + formatElement(jsx, {highlight: true, theme: 'beautiful'}); }).toThrow( 'pretty-format: Option "theme" must be of type "object" but instead received "string".', );