UNPKG

2.31 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. 2018,2019. 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 });
7/**
8 * Helper function for skipping tests when a certain condition is met.
9 *
10 * @example
11 * ```ts
12 * skipIf(
13 * !features.freeFormProperties,
14 * describe,
15 * 'free-form properties (strict: false)',
16 * () => {
17 * // the tests
18 * }
19 * );
20 * ```
21 *
22 * @param skip - Should the test case/suite be skipped?
23 * @param verb - The function to invoke to define the test case or the test
24 * suite, e.g. `it` or `describe`.
25 * @param name - The test name (the first argument of `verb` function).
26 * @param args - Additional arguments (framework specific), typically a function
27 * implementing the test.
28 */
29function skipIf(skip, verb, name, ...args) {
30 if (skip) {
31 return verb.skip(`[SKIPPED] ${name}`, ...args);
32 }
33 else {
34 return verb(name, ...args);
35 }
36}
37exports.skipIf = skipIf;
38/**
39 * Helper function for skipping tests on Travis CI.
40 *
41 * @example
42 *
43 * ```ts
44 * skipOnTravis(it, 'does something when some condition', async () => {
45 * // the test
46 * });
47 * ```
48 *
49 * @param verb - The function to invoke to define the test case or the test
50 * suite, e.g. `it` or `describe`.
51 * @param name - The test name (the first argument of `verb` function).
52 * @param args - Additional arguments (framework specific), typically a function
53 * implementing the test.
54 */
55function skipOnTravis(verb, name, ...args) {
56 if (process.env.TRAVIS) {
57 return verb.skip(`[SKIPPED ON TRAVIS] ${name}`, ...args);
58 }
59 else {
60 return verb(name, ...args);
61 }
62}
63exports.skipOnTravis = skipOnTravis;
64/**
65 * Helper function for skipping tests on Travis env - legacy variant
66 * supporting `it` only.
67 *
68 * @param expectation - The test name (the first argument of `it` function).
69 * @param callback - The test function (the second argument of `it` function).
70 *
71 * @deprecated Use `skipOnTravis(it, name, fn)` instead.
72 */
73function itSkippedOnTravis(expectation, callback) {
74 skipOnTravis(it, expectation, callback);
75}
76exports.itSkippedOnTravis = itSkippedOnTravis;
77//# sourceMappingURL=skip.js.map
\No newline at end of file