@zohodesk/unit-testing-framework 0.0.27-experimental → 0.0.28-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.
- package/README.md +12 -20
- package/build/src/runner/jest-runner.js +1 -1
- package/build/src/utils/logger.js +22 -20
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @zohodesk/unit-testing-framework
|
|
2
2
|
|
|
3
|
-
A modular, Jest-based unit testing framework designed to plug into existing CLI pipelines. Runs Jest **programmatically** via `@jest/core` (no shell execution), ships with sensible defaults,
|
|
3
|
+
A modular, Jest-based unit testing framework designed to plug into existing CLI pipelines. Runs Jest **programmatically** via `@jest/core` (no shell execution), ships with sensible defaults, HTML report generation via `jest-html-reporter`, and automatic Jest globals injection.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -17,18 +17,10 @@ unit-testing-framework/
|
|
|
17
17
|
│ │ └── runner-base.js # buildArgv() & executeJest() via @jest/core
|
|
18
18
|
│ ├── config/
|
|
19
19
|
│ │ └── default-config.js # getDefaultConfig() – framework defaults
|
|
20
|
-
│ ├── reporters/
|
|
21
|
-
│ │ ├── default-reporter.js # Console reporter (pass/fail/skip summary)
|
|
22
|
-
│ │ ├── html-reporter.js # Self-contained HTML report generator
|
|
23
|
-
│ │ ├── html-template.js # HTML markup generation functions
|
|
24
|
-
│ │ ├── reporter-utils.js # Shared utils (timer, escapeHtml, stripAnsi)
|
|
25
|
-
│ │ └── templates/
|
|
26
|
-
│ │ ├── report-script.js # Client-side JS (filters, collapsible suites)
|
|
27
|
-
│ │ └── report.css # Dark-themed report stylesheet
|
|
28
20
|
│ ├── environment/
|
|
29
21
|
│ │ └── globals-inject.js # Injects jest into globalThis (setup file)
|
|
30
22
|
│ └── utils/
|
|
31
|
-
│ └── logger.js # Colored console logger
|
|
23
|
+
│ └── logger.js # Colored console logger utility
|
|
32
24
|
├── build/ # Transpiled output (published to npm)
|
|
33
25
|
├── examples/
|
|
34
26
|
│ └── consumer-cli.js # Example CLI integration
|
|
@@ -107,18 +99,18 @@ The framework provides a complete Jest config via `getDefaultConfig(projectRoot)
|
|
|
107
99
|
|
|
108
100
|
Two reporters are enabled by default:
|
|
109
101
|
|
|
110
|
-
1.
|
|
111
|
-
2.
|
|
102
|
+
1. **`default`** — Jest's built-in console reporter, prints pass/fail/skip summary to the terminal.
|
|
103
|
+
2. **`jest-html-reporter`** — generates an HTML test report using the [`jest-html-reporter`](https://www.npmjs.com/package/jest-html-reporter) package.
|
|
112
104
|
|
|
113
|
-
#### HTML Reporter
|
|
105
|
+
#### HTML Reporter Configuration
|
|
114
106
|
|
|
115
|
-
| Option |
|
|
107
|
+
| Option | Value | Description |
|
|
116
108
|
|---|---|---|
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
| `outputPath` | `<rootDir>/test-slices/unit-test/unit_reports/report.html` | Path for the generated report |
|
|
110
|
+
| `pageTitle` | `Unit Test Report` | Page title |
|
|
111
|
+
| `includeFailureMsg` | `true` | Show failure messages in the report |
|
|
112
|
+
| `includeSuiteFailure` | `true` | Show suite-level failures |
|
|
113
|
+
| `theme` | `darkTheme` | Dark-themed report |
|
|
122
114
|
|
|
123
115
|
### Globals Injection
|
|
124
116
|
|
|
@@ -150,7 +142,7 @@ if (command === 'unit-test') {
|
|
|
150
142
|
|
|
151
143
|
## Build
|
|
152
144
|
|
|
153
|
-
Source is written in ESM and transpiled to CommonJS via Babel
|
|
145
|
+
Source is written in ESM and transpiled to CommonJS via Babel.
|
|
154
146
|
|
|
155
147
|
```bash
|
|
156
148
|
npm run build # Transpile src/ → build/
|
|
@@ -10,7 +10,7 @@ async function createJestRunner(options = {}) {
|
|
|
10
10
|
const {
|
|
11
11
|
projectRoot = process.cwd(),
|
|
12
12
|
testPathPattern,
|
|
13
|
-
watch = false
|
|
13
|
+
watch = false // Re-runs tests automatically when source files change
|
|
14
14
|
} = options;
|
|
15
15
|
|
|
16
16
|
// ── 1. Build framework-controlled config ───────────────────
|
|
@@ -4,25 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Logger = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.consoleLogger = console;
|
|
18
|
-
}
|
|
19
|
-
error(err) {
|
|
20
|
-
this.consoleLogger.error(err);
|
|
21
|
-
}
|
|
22
|
-
info() {}
|
|
7
|
+
const COLORS = {
|
|
8
|
+
success: '\x1b[36m',
|
|
9
|
+
failure: '\x1b[31m',
|
|
10
|
+
info: '\x1b[33m',
|
|
11
|
+
reset: '\x1b[0m'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
const consoleLogger = console;
|
|
16
|
+
const Logger = exports.Logger = {
|
|
23
17
|
log(type, message) {
|
|
24
|
-
const color =
|
|
25
|
-
|
|
18
|
+
const color = COLORS[type] || COLORS.reset;
|
|
19
|
+
consoleLogger.log(`${color}${message}${COLORS.reset}`);
|
|
20
|
+
},
|
|
21
|
+
error(message) {
|
|
22
|
+
consoleLogger.error(`${COLORS.failure}${message}${COLORS.reset}`);
|
|
23
|
+
},
|
|
24
|
+
info(message) {
|
|
25
|
+
consoleLogger.log(`${COLORS.info}${message}${COLORS.reset}`);
|
|
26
|
+
},
|
|
27
|
+
success(message) {
|
|
28
|
+
consoleLogger.log(`${COLORS.success}${message}${COLORS.reset}`);
|
|
26
29
|
}
|
|
27
|
-
}
|
|
28
|
-
const Logger = exports.Logger = new LoggerImpl();
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/unit-testing-framework",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28-experimental",
|
|
4
4
|
"description": "A modular Jest-based unit testing framework",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
|
14
|
-
"lint": "eslint src/ index.js",
|
|
15
14
|
"build": "babel src -d build/src --copy-files && babel index.js --out-file build/index.js",
|
|
16
15
|
"prepublishOnly": "npm run build",
|
|
17
16
|
"clean": "rm -rf build && npm run build"
|