Skip to content

Commit 4986b11

Browse files
authored
Merge pull request #193 from Hargne/bugfix/package-json-config
Bugfix/package json config
2 parents a66c8f3 + 6d1d416 commit 4986b11

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules/
44
test-report/
55
dist/
66
report.html
7+
test-report.html

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,24 @@ To run the reporter as a test results processor (after Jest is complete instead
6262
}
6363
```
6464

65-
***Note:** When running as a testResultsProcessor, the configuration needs be placed within a new file named `jesthtmlreporter.config.json` residing in the root folder.*
65+
**Note:** When running as a testResultsProcessor, the configuration needs either to be placed within a new file named `jesthtmlreporter.config.json` residing in the root folder
66+
67+
```JSON
68+
{
69+
"pageTitle": "Test Report",
70+
}
71+
```
72+
73+
or via adding a key to `package.json` named "jest-html-reporter":
74+
75+
```JSON
76+
{
77+
...
78+
"jest-html-reporter": {
79+
"pageTitle": "Test Report",
80+
}
81+
}
82+
```
6683

6784
## 📌 Configuration Options (All Optional)
6885

@@ -93,7 +110,7 @@ All the configuration options provided in the table above are available via envi
93110

94111
**Example:** `customScriptPath` -> `JEST_HTML_REPORTER_CUSTOM_SCRIPT_PATH`
95112

96-
***NOTE:** Environment variables will take precedence over configurations set in jesthtmlreporter.config.json and package.json*
113+
**\*NOTE:** Environment variables will take precedence over configurations set in jesthtmlreporter.config.json and package.json\*
97114

98115
### CI Example
99116

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jest-html-reporter",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Jest test results processor for generating a summary in HTML",
55
"main": "dist/index.js",
66
"unpkg": "dist/index.js",

src/extractConfiguration.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export default function (cliConfig: unknown): JestHTMLReporterConfiguration {
111111
path.join(process.cwd(), "jesthtmlreporter.config.json")
112112
);
113113
const packageJsonConfig =
114-
readJsonFile(path.join(process.cwd(), "package.json"))?.jest || {};
114+
readJsonFile(path.join(process.cwd(), "package.json"))[
115+
"jest-html-reporter"
116+
] || {};
115117

116118
// Merge configurations in priority order (with sanitization)
117119
return {

0 commit comments

Comments
 (0)