Skip to content

Commit c23f53d

Browse files
committed
fix mocha_extensions
1 parent 8468a7a commit c23f53d

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

dev/test/util/mocha_extensions.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,31 @@ import {describe, it} from 'mocha';
2222
// Helper to make a type itselt (T) and optionally union that with (T['skip'])
2323
type tOrSkipT<T> = T | (T extends {skip: unknown} ? T['skip'] : T);
2424

25-
interface ExtendMochaTypeWithHelpers<T> {
26-
// Declare helpers
27-
skipEnterprise: tOrSkipT<T>;
28-
skipEmulator: tOrSkipT<T>;
29-
skipClassic: tOrSkipT<T>;
30-
}
31-
3225
declare module 'mocha' {
33-
type TestFunction = ExtendMochaTypeWithHelpers<TestFunction>;
34-
type PendingTestFunction = ExtendMochaTypeWithHelpers<PendingTestFunction>;
35-
type SuiteFunction = ExtendMochaTypeWithHelpers<SuiteFunction>;
36-
type PendingSuiteFunction = ExtendMochaTypeWithHelpers<PendingSuiteFunction>;
26+
// eslint-disable-next-line @typescript-eslint/no-namespace
27+
interface TestFunction {
28+
skipEnterprise: tOrSkipT<TestFunction>;
29+
skipEmulator: tOrSkipT<TestFunction>;
30+
skipClassic: tOrSkipT<TestFunction>;
31+
}
32+
33+
interface PendingTestFunction {
34+
skipEnterprise: tOrSkipT<PendingTestFunction>;
35+
skipEmulator: tOrSkipT<PendingTestFunction>;
36+
skipClassic: tOrSkipT<PendingTestFunction>;
37+
}
38+
39+
interface SuiteFunction {
40+
skipEnterprise: tOrSkipT<SuiteFunction>;
41+
skipEmulator: tOrSkipT<SuiteFunction>;
42+
skipClassic: tOrSkipT<SuiteFunction>;
43+
}
44+
45+
interface PendingSuiteFunction {
46+
skipEnterprise: tOrSkipT<PendingSuiteFunction>;
47+
skipEmulator: tOrSkipT<PendingSuiteFunction>;
48+
skipClassic: tOrSkipT<PendingSuiteFunction>;
49+
}
3750
}
3851

3952
// Define helpers
@@ -85,4 +98,6 @@ export function mixinSkipImplementations(obj: unknown): void {
8598
}
8699

87100
// TODO add mocha functions that must be extended
88-
[it, it.skip, describe, describe.skip].forEach(mixinSkipImplementations);
101+
[global.it, global.describe, it, it.skip, describe, describe.skip].forEach(
102+
mixinSkipImplementations,
103+
);

0 commit comments

Comments
 (0)