Skip to content

Commit c7e14ca

Browse files
committed
feat(testlab): rework itSkippedOnTravis to support Jest framework
Describe referenced Mocha types directly in testlab to avoid compile-time dependency on Mocha types, some of which are not compatible with Jest. Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
1 parent 84072ec commit c7e14ca

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/testlab/src/skip-travis.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6-
// tslint:disable-next-line:no-any
7-
export type TestCallbackRetval = void | PromiseLike<any>;
6+
// Simplified test function type from Mocha
7+
export interface TestFn {
8+
(this: TestContext): PromiseLike<unknown>;
9+
(this: TestContext, done: Function): void;
10+
}
11+
12+
// Type of "this" object provided by Mocha to test functions
13+
export interface TestContext {
14+
skip(): this;
15+
timeout(ms: number | string): this;
16+
retries(n: number): this;
17+
slow(ms: number): this;
18+
// tslint:disable-next-line:no-any
19+
[index: string]: any;
20+
}
821

922
/**
1023
* Helper function for skipping tests on Travis env
@@ -13,10 +26,7 @@ export type TestCallbackRetval = void | PromiseLike<any>;
1326
*/
1427
export function itSkippedOnTravis(
1528
expectation: string,
16-
callback?: (
17-
this: Mocha.ITestCallbackContext,
18-
done: MochaDone,
19-
) => TestCallbackRetval,
29+
callback?: TestFn,
2030
): void {
2131
if (process.env.TRAVIS) {
2232
it.skip(`[SKIPPED ON TRAVIS] ${expectation}`, callback);

0 commit comments

Comments
 (0)