( testObj: T, testFunc: Mocha.TestFunction | Mocha.ExclusiveTestFunction | Mocha.PendingTestFunction, innerTest: (testObj: T) => Promise<ModeHandler>, )
| 19 | import { assertEqualLines, reloadConfiguration, setupWorkspace } from './testUtils'; |
| 20 | |
| 21 | function 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 | |
| 55 | export const newTest = (testObj: ITestObject) => newTestGeneric(testObj, test, testIt); |
| 56 |
no test coverage detected