Skip to content

Commit

Permalink
Merge pull request #18 from wichopy/master
Browse files Browse the repository at this point in the history
Env var for report title and use case example added to readme.
  • Loading branch information
Hargne committed Nov 19, 2017
2 parents 8aafbf8 + 68ed9fc commit 01e3403
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ Have a look at the default styling (located within this repository at *src/style

## Continuous Integration

The output path can be set with a environment variable for dynamic file saving paths in different environments. Useful for CI
The output path and report title can be set with an environment variable for dynamic file saving paths in different environments.

Values in package.json will take precedence over environment variables.

Here is an example of dynamically naming your output file and test report title to match your current branch that one might see in a automated deployment pipeline before running their tests.

~~~ bash
export TEST_REPORT_PATH=/home/username/jest-test-output/test-reports.html
~~~
export BRANCH_NAME=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`
export TEST_REPORT_PATH=/home/username/jest-test-output/test-reports/"$BRANCH_NAME".html
export TEST_REPORT_TITLE="$BRANCH_NAME"\ Test\ Report
4 changes: 2 additions & 2 deletions src/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ const createHtml = (stylesheet) => xmlbuilder.create({
html: {
head: {
meta: { '@charset': 'utf-8' },
title: { '#text': config.pageTitle || 'Test suite' },
title: { '#text': config.pageTitle || process.env.TEST_REPORT_TITLE || 'Test suite' },
style: { '@type': 'text/css', '#text': stylesheet },
},
body: {
h1: { '#text': config.pageTitle || 'Test suite' },
h1: { '#text': config.pageTitle || process.env.TEST_REPORT_TITLE || 'Test suite' },
},
},
});
Expand Down

0 comments on commit 01e3403

Please sign in to comment.