UNPKG

1.92 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
3// Node module: @loopback/testlab
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.skipOnTravis = exports.skipIf = void 0;
8/**
9 * Helper function for skipping tests when a certain condition is met.
10 *
11 * @example
12 * ```ts
13 * skipIf(
14 * !features.freeFormProperties,
15 * describe,
16 * 'free-form properties (strict: false)',
17 * () => {
18 * // the tests
19 * }
20 * );
21 * ```
22 *
23 * @param skip - Should the test case/suite be skipped?
24 * @param verb - The function to invoke to define the test case or the test
25 * suite, e.g. `it` or `describe`.
26 * @param name - The test name (the first argument of `verb` function).
27 * @param args - Additional arguments (framework specific), typically a function
28 * implementing the test.
29 */
30function skipIf(skip, verb, name, ...args) {
31 if (skip) {
32 return verb.skip(`[SKIPPED] ${name}`, ...args);
33 }
34 else {
35 return verb(name, ...args);
36 }
37}
38exports.skipIf = skipIf;
39/**
40 * Helper function for skipping tests on Travis CI.
41 *
42 * @example
43 *
44 * ```ts
45 * skipOnTravis(it, 'does something when some condition', async () => {
46 * // the test
47 * });
48 * ```
49 *
50 * @param verb - The function to invoke to define the test case or the test
51 * suite, e.g. `it` or `describe`.
52 * @param name - The test name (the first argument of `verb` function).
53 * @param args - Additional arguments (framework specific), typically a function
54 * implementing the test.
55 */
56function skipOnTravis(verb, name, ...args) {
57 if (process.env.TRAVIS) {
58 return verb.skip(`[SKIPPED ON TRAVIS] ${name}`, ...args);
59 }
60 else {
61 return verb(name, ...args);
62 }
63}
64exports.skipOnTravis = skipOnTravis;
65//# sourceMappingURL=skip.js.map
\No newline at end of file