Skip to content

Commit 422c412

Browse files
authored
chore: upgrade TSTyche (#15596)
1 parent c47bb8c commit 422c412

File tree

10 files changed

+310
-268
lines changed

10 files changed

+310
-268
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"strip-json-comments": "^3.1.1",
7878
"tempy": "^1.0.0",
7979
"ts-node": "^10.5.0",
80-
"tstyche": "^3.0.0",
80+
"tstyche": "^4.0.0-rc.0",
8181
"typescript": "^5.0.4",
8282
"typescript-eslint": "^8.26.0",
8383
"webpack": "^5.68.0",

packages/expect/__typetests__/expectTyped.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ describe('Expect', () => {
1919
expect(_expect(100).toTypedEqual(100)).type.toBe<void>();
2020
expect(_expect(101).not.toTypedEqual(100)).type.toBe<void>();
2121

22-
expect(_expect(100).toTypedEqual('three')).type.toRaiseError(
23-
"Argument of type 'string' is not assignable to parameter of type 'number'.",
24-
);
22+
expect(_expect(100).toTypedEqual).type.not.toBeCallableWith('three');
2523
});
2624
});

packages/jest-expect/__typetests__/jest-expect.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ describe('JestExpect', () => {
3838
expect(jestExpect(100).toTypedEqual(100)).type.toBe<void>();
3939
expect(jestExpect(101).not.toTypedEqual(100)).type.toBe<void>();
4040

41-
expect(jestExpect(100).toTypedEqual('three')).type.toRaiseError(
42-
"Argument of type 'string' is not assignable to parameter of type 'number'.",
43-
);
41+
expect(jestExpect(100).toTypedEqual).type.not.toBeCallableWith('three');
4442
});
4543
});

packages/jest-mock/__typetests__/Mocked.test.ts

Lines changed: 64 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ describe('Mocked', () => {
3333
>();
3434

3535
expect(
36-
MockSomeClass.prototype.methodA.mockReturnValue('true'),
37-
).type.toRaiseError();
36+
MockSomeClass.prototype.methodA.mockReturnValue,
37+
).type.not.toBeCallableWith('true');
3838
expect(
39-
MockSomeClass.prototype.methodB.mockImplementation(
40-
(a: string, b?: string) => {
41-
return;
42-
},
43-
),
44-
).type.toRaiseError();
39+
MockSomeClass.prototype.methodB.mockImplementation,
40+
).type.not.toBeCallableWith((a: string, b?: string) => {
41+
return;
42+
});
4543

4644
expect(MockSomeClass.mock.instances[0].methodA.mock.calls[0]).type.toBe<
4745
[]
@@ -59,14 +57,14 @@ describe('Mocked', () => {
5957
[a: string, b?: number]
6058
>();
6159

60+
expect(mockSomeInstance.methodA.mockReturnValue).type.not.toBeCallableWith(
61+
'true',
62+
);
6263
expect(
63-
mockSomeInstance.methodA.mockReturnValue('true'),
64-
).type.toRaiseError();
65-
expect(
66-
mockSomeInstance.methodB.mockImplementation((a: string, b?: string) => {
67-
return;
68-
}),
69-
).type.toRaiseError();
64+
mockSomeInstance.methodB.mockImplementation,
65+
).type.not.toBeCallableWith((a: string, b?: string) => {
66+
return;
67+
});
7068

7169
expect(new SomeClass('sample')).type.toBeAssignableWith(mockSomeInstance);
7270
});
@@ -80,10 +78,10 @@ describe('Mocked', () => {
8078

8179
expect(mockFunction.mock.calls[0]).type.toBe<[a: string, b?: number]>();
8280

83-
expect(mockFunction.mockReturnValue(123)).type.toRaiseError();
84-
expect(
85-
mockFunction.mockImplementation((a: boolean, b?: number) => true),
86-
).type.toRaiseError();
81+
expect(mockFunction.mockReturnValue).type.not.toBeCallableWith(123);
82+
expect(mockFunction.mockImplementation).type.not.toBeCallableWith(
83+
(a: boolean, b?: number) => true,
84+
);
8785

8886
expect(someFunction).type.toBeAssignableWith(mockFunction);
8987
});
@@ -99,12 +97,10 @@ describe('Mocked', () => {
9997

10098
expect(mockAsyncFunction.mock.calls[0]).type.toBe<[Array<boolean>]>();
10199

102-
expect(mockAsyncFunction.mockResolvedValue(123)).type.toRaiseError();
103-
expect(
104-
mockAsyncFunction.mockImplementation((a: Array<boolean>) =>
105-
Promise.resolve(true),
106-
),
107-
).type.toRaiseError();
100+
expect(mockAsyncFunction.mockResolvedValue).type.not.toBeCallableWith(123);
101+
expect(mockAsyncFunction.mockImplementation).type.not.toBeCallableWith(
102+
(a: Array<boolean>) => Promise.resolve(true),
103+
);
108104

109105
expect(someAsyncFunction).type.toBeAssignableWith(mockAsyncFunction);
110106
});
@@ -130,23 +126,23 @@ describe('Mocked', () => {
130126
[a: number, b?: string]
131127
>();
132128

133-
expect(mockFunctionObject.mockReturnValue(123)).type.toRaiseError();
134-
expect(
135-
mockFunctionObject.mockImplementation(() => true),
136-
).type.toRaiseError();
129+
expect(mockFunctionObject.mockReturnValue).type.not.toBeCallableWith(123);
130+
expect(mockFunctionObject.mockImplementation).type.not.toBeCallableWith(
131+
() => true,
132+
);
137133

138134
expect(mockFunctionObject.one.more.time.mock.calls[0]).type.toBe<
139135
[time: number]
140136
>();
141137

142138
expect(
143-
mockFunctionObject.one.more.time.mockReturnValue(123),
144-
).type.toRaiseError();
139+
mockFunctionObject.one.more.time.mockReturnValue,
140+
).type.not.toBeCallableWith(123);
145141
expect(
146-
mockFunctionObject.one.more.time.mockImplementation((time: string) => {
147-
return;
148-
}),
149-
).type.toRaiseError();
142+
mockFunctionObject.one.more.time.mockImplementation,
143+
).type.not.toBeCallableWith((time: string) => {
144+
return;
145+
});
150146

151147
expect(someFunctionObject).type.toBeAssignableWith(mockFunctionObject);
152148
});
@@ -211,57 +207,51 @@ describe('Mocked', () => {
211207
[a: string, b?: number]
212208
>();
213209

214-
expect(mockObject.methodA.mockReturnValue(123)).type.toRaiseError();
215-
expect(
216-
mockObject.methodA.mockImplementation((a: number) => 123),
217-
).type.toRaiseError();
218-
expect(mockObject.methodB.mockReturnValue(123)).type.toRaiseError();
219-
expect(
220-
mockObject.methodB.mockImplementation((b: number) => 123),
221-
).type.toRaiseError();
222-
expect(mockObject.methodC.mockReturnValue(123)).type.toRaiseError();
223-
expect(
224-
mockObject.methodC.mockImplementation((c: number) => 123),
225-
).type.toRaiseError();
210+
expect(mockObject.methodA.mockReturnValue).type.not.toBeCallableWith(123);
211+
expect(mockObject.methodA.mockImplementation).type.not.toBeCallableWith(
212+
(a: number) => 123,
213+
);
214+
expect(mockObject.methodB.mockReturnValue).type.not.toBeCallableWith(123);
215+
expect(mockObject.methodB.mockImplementation).type.not.toBeCallableWith(
216+
(b: number) => 123,
217+
);
218+
expect(mockObject.methodC.mockReturnValue).type.not.toBeCallableWith(123);
219+
expect(mockObject.methodC.mockImplementation).type.not.toBeCallableWith(
220+
(c: number) => 123,
221+
);
226222

227-
expect(mockObject.one.more.time.mockReturnValue(123)).type.toRaiseError();
223+
expect(mockObject.one.more.time.mockReturnValue).type.not.toBeCallableWith(
224+
123,
225+
);
228226
expect(
229-
mockObject.one.more.time.mockImplementation((t: boolean) => 123),
230-
).type.toRaiseError();
227+
mockObject.one.more.time.mockImplementation,
228+
).type.not.toBeCallableWith((t: boolean) => 123);
231229

232230
expect(
233-
mockObject.SomeClass.prototype.methodA.mockReturnValue(123),
234-
).type.toRaiseError();
231+
mockObject.SomeClass.prototype.methodA.mockReturnValue,
232+
).type.not.toBeCallableWith(123);
235233
expect(
236-
mockObject.SomeClass.prototype.methodA.mockImplementation(
237-
(a: number) => 123,
238-
),
239-
).type.toRaiseError();
234+
mockObject.SomeClass.prototype.methodA.mockImplementation,
235+
).type.not.toBeCallableWith((a: number) => 123);
240236
expect(
241-
mockObject.SomeClass.prototype.methodB.mockReturnValue(123),
242-
).type.toRaiseError();
237+
mockObject.SomeClass.prototype.methodB.mockReturnValue,
238+
).type.not.toBeCallableWith(123);
243239
expect(
244-
mockObject.SomeClass.prototype.methodB.mockImplementation(
245-
(a: number) => 123,
246-
),
247-
).type.toRaiseError();
240+
mockObject.SomeClass.prototype.methodB.mockImplementation,
241+
).type.not.toBeCallableWith((a: number) => 123);
248242

249243
expect(
250-
mockObject.someClassInstance.methodA.mockReturnValue(123),
251-
).type.toRaiseError();
244+
mockObject.someClassInstance.methodA.mockReturnValue,
245+
).type.not.toBeCallableWith(123);
252246
expect(
253-
mockObject.someClassInstance.methodA.mockImplementation(
254-
(a: number) => 123,
255-
),
256-
).type.toRaiseError();
247+
mockObject.someClassInstance.methodA.mockImplementation,
248+
).type.not.toBeCallableWith((a: number) => 123);
257249
expect(
258-
mockObject.someClassInstance.methodB.mockReturnValue(123),
259-
).type.toRaiseError();
250+
mockObject.someClassInstance.methodB.mockReturnValue,
251+
).type.not.toBeCallableWith(123);
260252
expect(
261-
mockObject.someClassInstance.methodB.mockImplementation(
262-
(a: number) => 123,
263-
),
264-
).type.toRaiseError();
253+
mockObject.someClassInstance.methodB.mockImplementation,
254+
).type.not.toBeCallableWith((a: number) => 123);
265255

266256
expect(someObject).type.toBeAssignableWith(mockObject);
267257
});

0 commit comments

Comments
 (0)