|
1 | | -/** Copyright (c) 2024, Manuel Lõhmus (MIT). */ |
| 1 | +/** Copyright (c) Manuel Lõhmus (MIT). */ |
2 | 2 |
|
3 | 3 | 'use strict'; |
4 | 4 |
|
@@ -55,7 +55,7 @@ testRunner('TESTS for config-sets', { skip: false }, (test) => { |
55 | 55 |
|
56 | 56 | /** |
57 | 57 | * Test runner. Function to run unit tests in the console. |
58 | | - * @author Manuel Lõhmus 2024 (MIT License) |
| 58 | + * @author Manuel Lõhmus (MIT License) |
59 | 59 | * @version 1.1.5 |
60 | 60 | * [2024-12-29] adde d functionality to select tests by ID in the command line arguments (e.g. --testIDs=1 2 3) |
61 | 61 | * @example `npm test '--'` or `node index.test.js` |
@@ -98,9 +98,9 @@ testRunner('TESTS for config-sets', { skip: false }, (test) => { |
98 | 98 | */ |
99 | 99 | function testRunner(runnerName, options, cb) { |
100 | 100 |
|
101 | | - var globalScope = this || globalThis; |
| 101 | + var globalContext = this || globalThis; |
102 | 102 |
|
103 | | - globalScope?.process?.on('uncaughtException', function noop() { }); |
| 103 | + globalContext?.process?.on('uncaughtException', function noop() { }); |
104 | 104 |
|
105 | 105 | testRunner.testRunnerOK = true; |
106 | 106 | clearTimeout(testRunner.exitTimeoutID); |
@@ -128,8 +128,8 @@ The following options are supported: |
128 | 128 | --testID Number of the test to run (e.g. node index.test.js --testID=1 --testID=2 --testID=3) |
129 | 129 | `); |
130 | 130 |
|
131 | | - if (globalScope?.process?.argv[1].endsWith(".js")) { exitPressKey(); } |
132 | | - else { globalScope?.process?.exit(0); } |
| 131 | + if (globalContext?.process?.argv[1].endsWith(".js")) { exitPressKey(); } |
| 132 | + else { globalContext?.process?.exit(0); } |
133 | 133 |
|
134 | 134 | return; |
135 | 135 | } |
@@ -284,42 +284,42 @@ The following options are supported: |
284 | 284 | print_stdout(); |
285 | 285 | } |
286 | 286 |
|
287 | | - globalScope?.process?.removeAllListeners('uncaughtException'); |
| 287 | + globalContext?.process?.removeAllListeners('uncaughtException'); |
288 | 288 |
|
289 | | - if (globalScope?.process?.argv[1].endsWith(".js")) { |
| 289 | + if (globalContext?.process?.argv[1].endsWith(".js")) { |
290 | 290 |
|
291 | 291 | exitPressKey(); |
292 | 292 | } |
293 | | - else if (globalScope?.process) { |
| 293 | + else if (globalContext?.process) { |
294 | 294 |
|
295 | 295 | if (!testRunnerOK) { testRunner.testRunnerOK = false; } |
296 | 296 |
|
297 | 297 | testRunner.exitTimeoutID = setTimeout(function (exit) { |
298 | 298 |
|
299 | 299 | exit(testRunner.testRunnerOK ? 0 : 1); |
300 | 300 |
|
301 | | - }, 100, globalScope?.process?.exit); |
| 301 | + }, 100, globalContext?.process?.exit); |
302 | 302 | } |
303 | 303 | } |
304 | 304 | } |
305 | 305 |
|
306 | 306 | function exitPressKey() { |
307 | 307 |
|
308 | | - globalScope?.process?.stdin.setRawMode(true); |
309 | | - globalScope?.process?.stdin.resume(); |
310 | | - globalScope?.process?.stdin.on('data', globalScope?.process?.exit.bind(globalScope?.process, testRunnerOK ? 0 : 1)); |
| 308 | + globalContext?.process?.stdin.setRawMode(true); |
| 309 | + globalContext?.process?.stdin.resume(); |
| 310 | + globalContext?.process?.stdin.on('data', globalContext?.process?.exit.bind(globalContext?.process, testRunnerOK ? 0 : 1)); |
311 | 311 |
|
312 | 312 | console.log('Press any key to exit'); |
313 | 313 | } |
314 | 314 |
|
315 | 315 | function arg_options() { |
316 | 316 |
|
317 | | - if ("undefined" === typeof globalScope?.process) { return {}; } |
| 317 | + if ("undefined" === typeof globalContext?.process) { return {}; } |
318 | 318 |
|
319 | 319 | var isKey = false, |
320 | 320 | key = '', |
321 | 321 | values, |
322 | | - args = globalScope?.process?.argv |
| 322 | + args = globalContext?.process?.argv |
323 | 323 | .slice(2) |
324 | 324 | .join('') |
325 | 325 | .split('') |
|
0 commit comments