@zohodesk/unit-testing-framework 0.0.13-experimental → 0.0.14-experimental
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _logger = require("../utils/logger");
|
|
7
8
|
/**
|
|
8
9
|
* default-reporter.js
|
|
9
10
|
*
|
|
@@ -24,12 +25,12 @@ class DefaultReporter {
|
|
|
24
25
|
}
|
|
25
26
|
onRunStart(_results, _options) {
|
|
26
27
|
this._startTime = Date.now();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, '\n╔══════════════════════════════════════════╗');
|
|
29
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, '║ Unit Testing Framework – Test Run ║');
|
|
30
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, '╚══════════════════════════════════════════╝\n');
|
|
30
31
|
}
|
|
31
32
|
onTestStart(test) {
|
|
32
|
-
|
|
33
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, ` ▶ Running: ${test.path}`);
|
|
33
34
|
}
|
|
34
35
|
onTestResult(_test, testResult, _aggregatedResults) {
|
|
35
36
|
const {
|
|
@@ -38,7 +39,7 @@ class DefaultReporter {
|
|
|
38
39
|
numPendingTests
|
|
39
40
|
} = testResult;
|
|
40
41
|
const icon = numFailingTests > 0 ? '✖' : '✔';
|
|
41
|
-
|
|
42
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, ` ${icon} Passed: ${numPassingTests} Failed: ${numFailingTests} Skipped: ${numPendingTests}`);
|
|
42
43
|
}
|
|
43
44
|
onRunComplete(_contexts, results) {
|
|
44
45
|
const elapsed = ((Date.now() - this._startTime) / 1000).toFixed(2);
|
|
@@ -47,12 +48,12 @@ class DefaultReporter {
|
|
|
47
48
|
numFailedTests,
|
|
48
49
|
numTotalTests
|
|
49
50
|
} = results;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, '\n──────────────────────────────────────────');
|
|
52
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, ` Total: ${numTotalTests}`);
|
|
53
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, ` Passed: ${numPassedTests}`);
|
|
54
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, ` Failed: ${numFailedTests}`);
|
|
55
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, ` Time: ${elapsed}s`);
|
|
56
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, '──────────────────────────────────────────\n');
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
exports.default = DefaultReporter;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Logger = void 0;
|
|
7
|
+
class LoggerImpl {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.SUCCESS_TYPE = 'success';
|
|
10
|
+
this.FAILURE_TYPE = 'failure';
|
|
11
|
+
this.INFO_TYPE = 'info';
|
|
12
|
+
this.colors = {
|
|
13
|
+
'success': ['\x1b[36m', '\x1b[0m'],
|
|
14
|
+
'failure': ['\x1b[31m', '\x1b[0m'],
|
|
15
|
+
'info': ['\x1b[33m', '\x1b[0m']
|
|
16
|
+
};
|
|
17
|
+
this.consoleLogger = console;
|
|
18
|
+
}
|
|
19
|
+
error(err) {
|
|
20
|
+
this.consoleLogger.error(err);
|
|
21
|
+
}
|
|
22
|
+
info() {}
|
|
23
|
+
log(type, message) {
|
|
24
|
+
const color = this.colors[type];
|
|
25
|
+
this.consoleLogger.log(`${color[0]}${message}${color[1]}\n`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const Logger = exports.Logger = new LoggerImpl();
|
package/package.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = globalSetup;
|
|
7
|
-
/**
|
|
8
|
-
* Global Setup
|
|
9
|
-
*
|
|
10
|
-
* Runs once before the entire test suite.
|
|
11
|
-
* Jest calls this module's default export.
|
|
12
|
-
*
|
|
13
|
-
* Consumer projects can override by setting `globalSetup`
|
|
14
|
-
* in their jest.unit.config.js to their own setup file.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
async function globalSetup(_globalConfig) {
|
|
18
|
-
// Store start timestamp for reporting
|
|
19
|
-
process.env.__UTL_START_TIME__ = Date.now().toString();
|
|
20
|
-
console.log('[unit-testing-framework] Global setup complete.');
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = globalTeardown;
|
|
7
|
-
/**
|
|
8
|
-
* Global Teardown
|
|
9
|
-
*
|
|
10
|
-
* Runs once after the entire test suite completes.
|
|
11
|
-
* Jest calls this module's default export.
|
|
12
|
-
*
|
|
13
|
-
* Consumer projects can override by setting `globalTeardown`
|
|
14
|
-
* in their jest.unit.config.js to their own teardown file.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
async function globalTeardown(_globalConfig) {
|
|
18
|
-
const startTime = Number(process.env.__UTL_START_TIME__ || Date.now());
|
|
19
|
-
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
20
|
-
console.log(`[unit-testing-framework] Global teardown complete. Total time: ${elapsed}s`);
|
|
21
|
-
|
|
22
|
-
// Cleanup environment variable
|
|
23
|
-
delete process.env.__UTL_START_TIME__;
|
|
24
|
-
}
|