All files / lib help.js

91.67% Statements 11/12
100% Branches 4/4
100% Functions 2/2
90.91% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280                    1x 1x   1x   1x   1x 1x   1x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1x     1x 1x    
"use strict";
/**
 * Help description.
 *
 * @function
 * @name help
 * @arg {function} d - Function to process option description.
 * @arg {function} cb - Callback to expand default help.
 */
 
require("colors");
var U = require("glace-utils");
 
var plugins = require("./plugins");
 
module.exports = (d, cb) => {
 
    d = d || U.switchColor();
    cb = cb || (o => o);
 
    var result = U.help(d)
        .usage("\nglace [options] [sequence-of-test-files-or-folders]".white.bold)
        .options({
            /* configuration */
            "user-config [path]": {
                describe: d("Path to JS file with configuration which will be",
                    "merged with override default configuration.",
                    "Default is 'cwd/config.js' (if it exists)."),
                type: "string",
                group: "Core:",
            },
            "session-name [name]": {
                describe: d("Tests run session name.",
                    "Default value includes word 'session' and datetime."),
                type: "string",
                group: "Core:",
            },
            "grep <pattern>": {
                alias: "g",
                describe: d("Filter tests by part of name (powered by mocha)."),
                type: "string",
                group: "Core:",
            },
            "include <sequence>": {
                describe: d("Sequence of test name parts separated by ' | '",
                    "in order to choose tests for run. Or path to json file",
                    "with test names and params."),
                type: "string",
                group: "Core:",
            },
            "exclude <sequence>": {
                describe: d("Sequence of test name parts separated by ' | '",
                    "in order to exclude tests from run. Or path to json file",
                    "with test names."),
                type: "string",
                group: "Core:",
            },
            "precise-match": {
                describe: d("Precise tests inclusion or exclusion (not substring pattern)."),
                type: "boolean",
                group: "Core:",
            },
            "report-dir [path]": {
                describe: d("Path to report folder. Default is 'cwd/report'."),
                type: "string",
                group: "Core:",
            },
            "dont-clear-report": {
                describe: d("Don't clear previous report on tests run."),
                type: "boolean",
                group: "Core:",
            },
            "dont-check-names": {
                describe: d("Don't check test names uniqueness",
                    "(usually useful in unit testing)."),
                type: "boolean",
                group: "Core:",
            },
            "failed-tests-path [path]": {
                describe: d("Path to save failed tests in JSON format.",
                    "Default is 'cwd/report/failed-tests.json'."),
                type: "string",
                group: "Core:",
            },
            "root-conftest <path>": {
                describe: d("Path to root conftest.js which will be loaded",
                    "before all."),
                type: "string",
                group: "Core:",
            },
            "languages <sequence>": {
                describe: d("List of tested languages separated with comma."),
                type: "string",
                group: "Core:",
            },
            "retry [times]": {
                describe: d("Number of times to retry failed test.",
                    "Default is 0."),
                type: "number",
                group: "Core:",
            },
            "chunk-retry [times]": {
                describe: d("Number of times to retry failed chunk.",
                    "Default is 0."),
                type: "number",
                group: "Core:",
            },
            "chunk-timeout [sec]": {
                describe: d("Time to execute chunk or hook, sec.",
                    "Default is 180."),
                type: "number",
                group: "Core:",
            },
            "uncaught [type]": {
                describe: d("Strategy to process uncaught exceptions.",
                    "Default value is 'log'. See details in",
                    "https://glacejs.github.io/glace-core"),
                type: "string",
                choices: [ "log", "fail", "mocha" ],
                group: "Core:",
            },
            "kill-procs <sequence>": {
                describe: d("List of process names separated with comma,",
                    "which will be killed before tests run."),
                type: "string",
                group: "Core:",
            },
            "debug-on-fail": {
                describe: d("Enter to interactive debug mode on step failure.",
                    "Incompatible with '--slaves' option."),
                type: "boolean",
                group: "Core:",
            },
            "exit-on-fail": {
                describe: d("Finish test run on first failure."),
                type: "boolean",
                group: "Core:",
            },
            "dots": {
                describe: d("Print dots instead of test & chunk names."),
                type: "boolean",
                group: "Core:",
            },
            "errors-now": {
                describe: d("Print error message immediately when it happened."),
                type: "boolean",
                group: "Core:",
            },
            "deep-errors": {
                describe: d("Print deep objects structure in error message."),
                type: "boolean",
                group: "Core:",
            },
            "interactive": {
                describe: d("Launch interactive mode to execute steps",
                    "manually in terminal. Incompatible with '--slaves' option."),
                alias: "i",
                type: "boolean",
                group: "Core:",
            },
            "slaves <number|auto>": {
                describe: d("Split tests by slaves and execute them in",
                    "separated processes in parallel."),
                type: "string",
                group: "Core:",
            },
            /* plugins */
            "list-plugins": {
                describe: d("List plugins end exit."),
                type: "boolean",
                group: "Plugins:",
            },
            "plugins-dir [path]": {
                describe: d("Path to custom plugins folder. By default it searches",
                    "plugins inside folder, where 'glace-core' is installed."),
                type: "string",
                group: "Plugins:",
            },
            "disable-default-plugins": {
                describe: d("Disable default plugins."),
                type: "boolean",
                group: "Plugins:",
            },
            /* xunit */
            "xunit": {
                describe: d("Activate xUnit reporter."),
                type: "boolean",
                group: "xUnit:",
            },
            "xunit-path [path]": {
                describe: d("Path to xUnit report. Default is 'cwd/report/xunit.xml'."),
                type: "string",
                group: "xUnit:",
            },
            "xunit-suite-name [name]": {
                describe: d("Tests suite name in xUnit report.",
                    "By default it's the same as session name."),
                type: "string",
                group: "xUnit:",
            },
            /* allure */
            "allure": {
                describe: d("Activate Allure reporter."),
                type: "boolean",
                group: "Allure:",
            },
            "allure-dir [path]": {
                describe: d("Path to allure report folder. Default is 'cwd/report/allure'."),
                type: "string",
                group: "Allure:",
            },
            /* testrail */
            "testrail": {
                describe: d("Activate TestRail reporter."),
                type: "boolean",
                group: "TestRail:",
            },
            "testrail-host <host>": {
                describe: d("TestRail host."),
                type: "string",
                group: "TestRail:",
            },
            "testrail-user <user>": {
                describe: d("TestRail username or email."),
                type: "string",
                group: "TestRail:",
            },
            "testrail-token <token>": {
                describe: d("TestRail token."),
                type: "string",
                group: "TestRail:",
            },
            "testrail-project-id <id>": {
                describe: d("TestRail project id."),
                type: "string",
                group: "TestRail:",
            },
            "testrail-suite-id <id>": {
                describe: d("TestRail suite id."),
                type: "string",
                group: "TestRail:",
            },
            "testrail-run-name <name>": {
                describe: d("TestRail run name."),
                type: "string",
                group: "TestRail:",
            },
            "testrail-run-desc <description>": {
                describe: d("TestRail run description."),
                type: "string",
                group: "TestRail:",
            },
            /* tools */
            "testrail-check": {
                describe: d("Check TestRail cases consistency with",
                    "implemented tests."),
                type: "boolean",
                group: "Tools:",
            },
            "list-steps [filter]": {
                describe: d("List available steps and exit."),
                group: "Tools:",
            },
            "list-tests [filter]": {
                describe: d("List collected tests and exit."),
                group: "Tools:",
            },
            "list-fixtures [filter]": {
                describe: d("List available fixtures and exit."),
                group: "Tools:",
            },
        });
 
    for (var help of plugins.getModules("pluginHelp")) {
        result = help(result, d);
    }
    result = cb(result);
    result.epilog("Have a green test ;)".green.bold).argv;
};