Skip to content

Commit

Permalink
Merge pull request #95 from Hargne/dev
Browse files Browse the repository at this point in the history
Release v3.0.0
  • Loading branch information
Hargne authored Mar 30, 2020
2 parents 4051a38 + 8af31f6 commit ff12e93
Show file tree
Hide file tree
Showing 38 changed files with 13,659 additions and 9,907 deletions.
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
["@babel/typescript", { "allowNamespaces": true }],
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
19 changes: 0 additions & 19 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts-prepend-node-path=true
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
language: node_js
node_js:
- "11.10.1"
- node
- lts/*
17 changes: 11 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# Contributing

So you want to contribute to the project? **How lovely!** Here are a few things to keep in mind when working with the project:

## Linting
[ESlint](https://eslint.org/) is used for style management. Make sure that your IDE recognizes the project's eslint config before you start developing.
## Code Quality

The format of the code is handled by the use of [Prettier](https://github.com/prettier/prettier). When coding, make sure that your IDE has access to use Prettier to format the code before committing the code to the repository.

### Testing

## Testing
This project is using [jest](https://github.com/facebook/jest) for testing and the test specifications should be placed within the _/test_ folder.
This project is using [Jest](https://github.com/facebook/jest) for testing and the test specifications should be placed within the _/test_ folder.
All functionality should have it's use-cases somewhat thoroughly tested (best sentence ever, thank you very much).

## Pull Requests

When you are done with your contribution, issue a pull request. The project maintainers will have a look at it as soon as possible!

## Have fun
🎺 This is the most important thing of all.
## Have fun

🎺 This is the most important thing of all.
84 changes: 46 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
<p align="center">
<p align="center" style="font-size: 3rem;margin: 0;">📜</p>
<h3 align="center">jest-html-reporter</h3>
<p align="center">
A <a href="https://github.com/facebook/jest">Jest</a> test results processor for generating a summary in HTML.
<br>
<a href="https://github.com/Hargne/jest-html-reporter/wiki"><strong>Documentation »</strong></a>
<br />
<br />
<img src="https://img.shields.io/npm/dm/jest-html-reporter?style=for-the-badge" alt="">
<img src="https://img.shields.io/travis/com/hargne/jest-html-reporter?style=for-the-badge">
<img src="https://img.shields.io/npm/v/jest-html-reporter?style=flat-square">
<img src="https://img.shields.io/npm/dm/jest-html-reporter?style=flat-square">
<img src="https://img.shields.io/travis/com/hargne/jest-html-reporter?style=flat-square">
<br />
<br />
Inspired by <a href="https://github.com/matthias-schuetz/karma-htmlfile-reporter">karma-htmlfile-reporter</a>
<br />
<br />
<hr />
<img src="https://user-images.githubusercontent.com/3501024/36374670-711b7cea-156c-11e8-8b7b-7fc5f38b1866.png" alt="">
<div style="text-align:center">
<img src="https://user-images.githubusercontent.com/3501024/77887991-d511c480-726b-11ea-9ed8-2e581206900c.png" alt="" style="max-width:75%">
</div>
<br />
<br />
</p>
</p>

***

## Installation

```shell
npm install jest-html-reporter --save-dev
$ yarn add jest-html-reporter --dev
```

## Usage

Configure Jest to process the test results by adding the following entry to the Jest config (jest.config.json):

```JSON
"reporters": [
"default",
Expand All @@ -35,57 +41,59 @@ Configure Jest to process the test results by adding the following entry to the
}]
]
```
As you run Jest from within the terminal, a file called *test-report.html* will be created within your root folder containing information about your tests.

As you run Jest from within the terminal, a file called _test-report.html_ will be created within your root folder containing information about your tests.

There are multiple configuration options available. To read more about these, please refer to the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/configuration).

### Alternative Usage as a Test Results Processor
#### Alternative Usage as a Test Results Processor

To run the reporter as a test results processor (after Jest is complete instead of running in parallel), add the following entry to the Jest config (jest.config.json):

```JSON
{
"testResultsProcessor": "./node_modules/jest-html-reporter"
}
```

**Note:** When running as a testResultsProcessor, the configuration needs be placed within a new file named `jesthtmlreporter.config.json` residing in the root folder.
**Note:** When running as a testResultsProcessor, the configuration needs be placed within a new file named `jesthtmlreporter.config.json` residing in the root folder.
More information about this can be found in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/configuration).

### Node Compatibility

## Node Compatibility
This plugin is compatible with Node version `^4.8.3`
<img src="https://img.shields.io/node/v/jest-html-reporter?style=flat-square">

---
This plugin is compatible with Node version `^4.8.3`

## Configuration

Please note that all configuration properties are optional.

| Property | Type | Description | Default
|--|--|--|--|
| `pageTitle` | `STRING` | The title of the document. This string will also be outputted on the top of the page. | `"Test Suite"`
| `outputPath` | `STRING` | The path to where the plugin will output the HTML report. The path must include the filename and end with .html | `"./test-report.html"`
| `includeFailureMsg` | `BOOLEAN` | If this setting is set to true, this will output the detailed failure message for each failed test. | `false`
| `includeConsoleLog` | `BOOLEAN` | If set to true, this will output all triggered console logs for each test suite. | `false`
| `styleOverridePath` | `STRING` | The path to a file containing CSS styles that should override the default styling.* | `null`
| `useCssFile` | `BOOLEAN` | If set to true, the CSS styles will link in the current theme's .css file instead of inlining its content on the page | `false`
| `customScriptPath` | `STRING` | Path to a javascript file that should be injected into the test report | `null`
| `theme` | `STRING` | The name of the reporter themes to use when rendering the report. You can find the available themes in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/Test-Report-Themes) | `"defaultTheme"`
| `logo` | `STRING` | Path to a logo that will be included in the header of the report | `null`
| `executionTimeWarningThreshold` | `NUMBER` | The threshold for test execution time (in seconds) in each test suite that will render a warning on the report page. 5 seconds is the default timeout in Jest. | `5`
| `dateFormat` | `STRING` | The format in which date/time should be formatted in the test report. Have a look in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/Date-Format) for the available date format variables. | `"yyyy-mm-dd HH:MM:ss"`
| `sort` | `STRING` | Sorts the test results using the given method. Available sorting methods can be found in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/Sorting-Methods). | `"default"`
| `statusIgnoreFilter` | `STRING` | A comma-separated string of the test result statuses that should be ignored when rendering the report. Available statuses are: `"passed"`, `"pending"`, `"failed"` | `null`
| `boilerplate` | `STRING` | The path to a boilerplate file that should be used to render the body of the test results into. `{jesthtmlreporter-content}` within the boilerplate will be replaced with the test results | `null`
| `append` | `BOOLEAN` | If set to true, new test results will be appended to the existing test report | `false`

> *The plugin will search for the *styleOverridePath* from the root directory, therefore there is no need to prepend the string with `./` or `../` - You can read more about the themes in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/Test-Report-Themes).
---
| Property | Type | Description | Default |
| ------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
| `append` | `BOOLEAN` | If set to true, new test results will be appended to the existing test report | `false` |
| `boilerplate` | `STRING` | The path to a boilerplate file that should be used to render the body of the test results into. `{jesthtmlreporter-content}` within the boilerplate will be replaced with the test results | `null` |
| `customScriptPath` | `STRING` | Path to a javascript file that should be injected into the test report | `null` |
| `dateFormat` | `STRING` | The format in which date/time should be formatted in the test report. Have a look in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/Date-Format) for the available date format variables. | `"yyyy-mm-dd HH:MM:ss"` |
| `executionTimeWarningThreshold` | `NUMBER` | The threshold for test execution time (in seconds) in each test suite that will render a warning on the report page. 5 seconds is the default timeout in Jest. | `5` |
| `includeConsoleLog` | `BOOLEAN` | If set to true, this will output all triggered console logs for each test suite. Please note that you have to run Jest together with `--verbose=false` in order to have Jest catch any logs during the tests. | `false` |
| `includeFailureMsg` | `BOOLEAN` | If this setting is set to true, this will output the detailed failure message for each failed test. | `false` |
| `logo` | `STRING` | Path to a logo that will be included in the header of the report | `null` |
| `outputPath` | `STRING` | The path to where the plugin will output the HTML report. The path must include the filename and end with .html | `"./test-report.html"` |
| `pageTitle` | `STRING` | The title of the document. This string will also be outputted on the top of the page. | `"Test Suite"` |
| `sort` | `STRING` | Sorts the test results using the given method. Available sorting methods can be found in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/Sorting-Methods). | `"default"` |
| `statusIgnoreFilter` | `STRING` | A comma-separated string of the test result statuses that should be ignored when rendering the report. Available statuses are: `"passed"`, `"pending"`, `"failed"` | `null` |
| `styleOverridePath` | `STRING` | The path to a file containing CSS styles that should override the default styling.\* | `null` |
| `useCssFile` | `BOOLEAN` | If set to true, the CSS styles will link in the current theme's .css file instead of inlining its content on the page | `false` |

> *The plugin will search for the *styleOverridePath\* from the root directory, therefore there is no need to prepend the string with `./` or `../` - You can read more about the themes in the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/Test-Report-Themes).
## Continuous Integration

Configuration may also be performed with environment variables for dynamic file saving paths in different environments. ***NOTE:** Environment variables will take precedence over configurations set in jesthtmlreporter.config.json and package.json*
Configuration may also be performed with environment variables for dynamic file saving paths in different environments. **\*NOTE:** Environment variables will take precedence over configurations set in jesthtmlreporter.config.json and package.json\*

#### Example

### Example
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
Expand All @@ -94,6 +102,6 @@ export JEST_HTML_REPORTER_OUTPUT_PATH=/home/username/jest-test-output/test-repor
export JEST_HTML_REPORTER_PAGE_TITLE="$BRANCH_NAME"\ Test\ Report
```

### Configuration Environment Variables
The environment variables reflect the configuration options available in JSON format. Please read the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/configuration#configuration-environment-variables) for more information on these variables.
#### Configuration Environment Variables

The environment variables reflect the configuration options available in JSON format. Please read the [documentation](https://github.com/Hargne/jest-html-reporter/wiki/configuration#configuration-environment-variables) for more information on these variables.
73 changes: 42 additions & 31 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
{
"roots": ["<rootDir>"],
"collectCoverage": true,
"collectCoverageFrom" : [
"src/**/*.{js,jsx}",
"!src/style.js",
"!**/test/*.{js,jsx}",
"!**/node_modules/**",
"!**/coverage/**",
"!**/vendor/**"
],
"coverageDirectory": "./coverage",
"coverageReporters": ["json", "html", "text", "text-summary"],
"coverageThreshold": {
"global": {
"branches": 50,
"functions": 50,
"lines": 50,
"statements": 50
}
},
"reporters": [
"default",
["./src", {
"pageTitle": "Test Suite Reporter",
"outputPath": "testResultsProcessorResult.html",
"includeFailureMsg": true,
"includeConsoleLog": true,
"useCssFile" : true,
"sort": "titleAsc"
}]
]
"roots": ["<rootDir>"],
"preset": "ts-jest",
"globals": {
"ts-jest": {
"babelConfig": true
}
},
"collectCoverage": true,
"collectCoverageFrom": [
"./src/**/*.{ts,tsx}",
"!src/style.ts",
"!**/test/*.{ts,tsx}",
"!**/node_modules/**",
"!**/coverage/**",
"!**/vendor/**"
],
"coverageDirectory": "./coverage",
"coverageReporters": ["json", "html", "text", "text-summary"],
"coverageThreshold": {
"global": {
"branches": 50,
"functions": 50,
"lines": 50,
"statements": 50
}
},
"verbose": false,
"reporters": [
"default",
[
"./dist",
{
"pageTitle": "Test Suite Reporter",
"outputPath": "testResultsProcessorResult.html",
"includeFailureMsg": true,
"includeConsoleLog": true,
"useCssFile": true,
"sort": "titleAsc",
"append": false
}
]
]
}
Loading

0 comments on commit ff12e93

Please sign in to comment.