Skip to content

Commit 4eae5a4

Browse files
pdepetrometa-codesync[bot]
authored andcommitted
Make Tintype VS Code mocks safe for Jest hoisting
Summary: Wrap the shared VS Code mock functions in lazy forwarding callbacks so Jest 29's hoisted `jest.mock()` factory does not evaluate top-level `const` mocks before initialization. Type the wrapper returns as `unknown` to satisfy strict xplat linting without changing runtime behavior. ___ Differential Revision: D116877448 fbshipit-source-id: 08c2fad9a34771175f4e942f74c49fa3d884df14
1 parent 6cc62e1 commit 4eae5a4

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

vscode/core/src/snapshot/__tests__/snapshot-provider.test.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ jest.mock('vscode', () => ({
3939
},
4040
},
4141
window: {
42-
showErrorMessage: mockShowErrorMessage,
43-
showInformationMessage: mockShowInformationMessage,
44-
showWarningMessage: mockShowWarningMessage,
45-
showSaveDialog: mockShowSaveDialog,
42+
showErrorMessage: (...args: unknown[]): unknown => mockShowErrorMessage(...args) as unknown,
43+
showInformationMessage: (...args: unknown[]): unknown =>
44+
mockShowInformationMessage(...args) as unknown,
45+
showWarningMessage: (...args: unknown[]): unknown => mockShowWarningMessage(...args) as unknown,
46+
showSaveDialog: (...args: unknown[]): unknown => mockShowSaveDialog(...args) as unknown,
4647
},
4748
workspace: {
4849
fs: {
4950
stat: (uri: unknown): Promise<unknown> => mockFsStat(uri) as Promise<unknown>,
5051
},
5152
},
5253
commands: {
53-
executeCommand: mockExecuteCommand,
54+
executeCommand: (...args: unknown[]): unknown => mockExecuteCommand(...args) as unknown,
5455
},
5556
Uri: {
5657
file: (fsPath: string) => ({fsPath, path: fsPath, scheme: 'file'}),

0 commit comments

Comments
 (0)