MCPcopy
hub / github.com/VSCodeVim/Vim / newTestGeneric

Function newTestGeneric

test/testSimplifier.ts:21–53  ·  view source on GitHub ↗
(
  testObj: T,
  testFunc: Mocha.TestFunction | Mocha.ExclusiveTestFunction | Mocha.PendingTestFunction,
  innerTest: (testObj: T) => Promise<ModeHandler>,
)

Source from the content-addressed store, hash-verified

19import { assertEqualLines, reloadConfiguration, setupWorkspace } from './testUtils';
20
21function newTestGeneric<T extends ITestObject | ITestWithRemapsObject>(
22 testObj: T,
23 testFunc: Mocha.TestFunction | Mocha.ExclusiveTestFunction | Mocha.PendingTestFunction,
24 innerTest: (testObj: T) => Promise<ModeHandler>,
25): void {
26 const stack = ((s) => (s ? s.split('\n').splice(2, 1).join('\n') : 'no stack available :('))(
27 new Error().stack,
28 );
29
30 testFunc(testObj.title, async () => {
31 const prevConfig = { ...Globals.mockConfiguration };
32 try {
33 if (testObj.config) {
34 Object.assign(Globals.mockConfiguration, testObj.config);
35 await reloadConfiguration(Globals.mockConfiguration);
36 }
37
38 if (vscode.window.activeTextEditor === undefined) {
39 await setupWorkspace();
40 }
41
42 await innerTest(testObj);
43 } catch (reason) {
44 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
45 reason.stack = stack;
46 throw reason;
47 } finally {
48 if (testObj.config) {
49 await reloadConfiguration(prevConfig);
50 }
51 }
52 });
53}
54
55export const newTest = (testObj: ITestObject) => newTestGeneric(testObj, test, testIt);
56

Callers 6

newTestFunction · 0.85
newTestOnlyFunction · 0.85
newTestSkipFunction · 0.85
newTestWithRemapsFunction · 0.85
newTestWithRemapsOnlyFunction · 0.85
newTestWithRemapsSkipFunction · 0.85

Calls 3

reloadConfigurationFunction · 0.90
setupWorkspaceFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected