Skip to content

Commit

Permalink
feat(testlab): rework itSkippedOnTravis to support Jest framework
Browse files Browse the repository at this point in the history
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š <[email protected]>
  • Loading branch information
bajtos committed May 31, 2019
1 parent 84072ec commit c7e14ca
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/testlab/src/skip-travis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

// tslint:disable-next-line:no-any
export type TestCallbackRetval = void | PromiseLike<any>;
// Simplified test function type from Mocha
export interface TestFn {
(this: TestContext): PromiseLike<unknown>;
(this: TestContext, done: Function): void;
}

// Type of "this" object provided by Mocha to test functions
export interface TestContext {
skip(): this;
timeout(ms: number | string): this;
retries(n: number): this;
slow(ms: number): this;
// tslint:disable-next-line:no-any
[index: string]: any;
}

/**
* Helper function for skipping tests on Travis env
Expand All @@ -13,10 +26,7 @@ export type TestCallbackRetval = void | PromiseLike<any>;
*/
export function itSkippedOnTravis(
expectation: string,
callback?: (
this: Mocha.ITestCallbackContext,
done: MochaDone,
) => TestCallbackRetval,
callback?: TestFn,
): void {
if (process.env.TRAVIS) {
it.skip(`[SKIPPED ON TRAVIS] ${expectation}`, callback);
Expand Down

0 comments on commit c7e14ca

Please sign in to comment.