Skip to content

Commit dfda079

Browse files
authored
chore: clean up typechecks of expect test files (#13393)
1 parent e23c5c7 commit dfda079

File tree

4 files changed

+419
-430
lines changed

4 files changed

+419
-430
lines changed

packages/expect/src/__tests__/extend.test.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import {equals, iterableEquality, subsetEquality} from '@jest/expect-utils';
1010
import {alignedAnsiStyleSerializer} from '@jest/test-utils';
1111
import * as matcherUtils from 'jest-matcher-utils';
12-
import importedExpect from '../';
12+
import jestExpect from '../';
1313

1414
expect.addSnapshotSerializer(alignedAnsiStyleSerializer);
1515

16-
importedExpect.extend({
16+
jestExpect.extend({
1717
toBeDivisibleBy(actual: number, expected: number) {
1818
const pass = actual % expected === 0;
1919
const message: () => string = pass
@@ -52,6 +52,11 @@ importedExpect.extend({
5252
});
5353

5454
declare module '../types' {
55+
interface AsymmetricMatchers {
56+
toBeDivisibleBy(expected: number): void;
57+
toBeSymbol(expected: symbol): void;
58+
toBeWithinRange(floor: number, ceiling: number): void;
59+
}
5560
interface Matchers<R> {
5661
toBeDivisibleBy(expected: number): R;
5762
toBeSymbol(expected: symbol): R;
@@ -64,17 +69,6 @@ declare module '../types' {
6469
}
6570
}
6671

67-
const jestExpect = importedExpect as typeof importedExpect & {
68-
not: {
69-
toBeDivisibleBy(expected: number): void;
70-
toBeWithinRange(floor: number, ceiling: number): void;
71-
};
72-
73-
toBeDivisibleBy(expected: number): void;
74-
toBeSymbol(expected: symbol): void;
75-
toBeWithinRange(floor: number, ceiling: number): void;
76-
};
77-
7872
it('is available globally when matcher is unary', () => {
7973
jestExpect(15).toBeDivisibleBy(5);
8074
jestExpect(15).toBeDivisibleBy(3);

packages/expect/src/__tests__/spyMatchers.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77

88
import * as Immutable from 'immutable';
99
import {alignedAnsiStyleSerializer} from '@jest/test-utils';
10-
import importedExpect from '../';
10+
import jestExpect from '../';
1111

1212
expect.addSnapshotSerializer(alignedAnsiStyleSerializer);
1313

14-
importedExpect.extend({
14+
jestExpect.extend({
1515
optionalFn(fn?: unknown) {
1616
const pass = fn === undefined || typeof fn === 'function';
1717
return {message: () => 'expect either a function or undefined', pass};
1818
},
1919
});
2020

21-
const jestExpect = importedExpect as typeof importedExpect & {
22-
optionalFn(fn?: unknown): void;
23-
};
21+
declare module '../types' {
22+
interface AsymmetricMatchers {
23+
optionalFn(fn?: unknown): void;
24+
}
25+
}
2426

2527
// Given a Jest mock function, return a minimal mock of a spy.
2628
const createSpy = (fn: jest.Mock) => {

0 commit comments

Comments
 (0)