Skip to content

Commit afcc430

Browse files
authored
Custom reporter (#103)
- Making Differencify compatible with differencify-jest-reporter - Save the captured image from the current test run to test the report path by default
1 parent 4301a61 commit afcc430

16 files changed

+2411
-2535
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ dist/
3333
docs/
3434
.vscode/
3535
differencify_reports/
36+
__differencified_output__/
37+
__current_output__/
3638
trace.json

.npmignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
src/
2-
examples/
32
.circleci/
43
.vscode/
54
.idea/

CHANGELOG.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
## [1.4.3] - 2018-7-21
1+
## [1.5.0] - 2018-08-30
2+
### Added
3+
- Making Differencify compatible with differencify-jest-reporter
4+
- Save the captured image from current test run to test report path by default
5+
6+
## [1.4.3] - 2018-07-21
27
### Updated
38
- Integrating greenkeeper
49
- Updating several packages
510

6-
## [1.4.2] - 2018-7-13
11+
## [1.4.2] - 2018-07-13
712
### Fixed
813
- Fixing issue with freezeImage command
914

10-
## [1.4.1] - 2018-6-22
15+
## [1.4.1] - 2018-06-22
1116
### Added
1217
- A prepare script to keep the artifact uptodated
1318

14-
## [1.4.0] - 2018-6-21
19+
## [1.4.0] - 2018-06-21
1520
### Changed
1621
- `toMatchScreenshot` updated to accept a callback parameter which is passed
1722
details of the comparison (See [API.md](/NimaSoroush/differencify/blob/master/API.md#detailed-result-information)
@@ -20,17 +25,17 @@
2025
### Added
2126
- NPM script `test:integration` to streamline running integration tests in Docker
2227

23-
## [1.3.4] - 2018-6-9
28+
## [1.3.4] - 2018-06-09
2429
### Fixed
2530
- Export module Differencify
2631
- Make Differencify running with vanilla node
2732
- Fix screenshot path issue for non jest
2833

29-
## [1.3.3] - 2018-6-6
34+
## [1.3.3] - 2018-06-06
3035
### Fixed
3136
- Bug fixed for custom test path
3237

33-
## [1.3.1] - 2018-5-25
38+
## [1.3.1] - 2018-05-25
3439
### Fixed
3540
- Bug fixed for testName not being picked up correctly
3641

README.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,44 @@ As you can see, you don't need to return `result` as `toMatchSnapshot` will auto
111111

112112
Same way as Jest [snapshots testing](http://facebook.github.io/jest/docs/en/snapshot-testing.html), to update the snapshots, run jest with `--updateSnapshot` or `-u` argument.
113113

114+
## Jest reporter
115+
116+
You can generate an index document of the saved images by using the differencify jest reporter.
117+
118+
```bash
119+
$ npm i -D differencify-jest-reporter
120+
```
121+
122+
Enable the reporter in your jest config:
123+
124+
```
125+
module.exports = {
126+
reporters: [
127+
'default', // keep the default reporter
128+
[
129+
'differencify-jest-reporter',
130+
{
131+
debug: true,
132+
reportPath: 'differencify_reports', // relative to root of project
133+
reportTypes: {
134+
html: 'index.html',
135+
json: 'index.json',
136+
},
137+
},
138+
],
139+
],
140+
};
141+
```
142+
143+
Alternatively, enable the reporter with the cli:
144+
145+
```
146+
jest --reporters default differencify-jest-reporter
147+
```
148+
149+
### Jest reporter output
150+
<p align="center"><img alt="differencify-report" src="images/differencify-report.png" width="500"></p>
151+
114152
## Usage with other test frameworks
115153
If you are using other test frameworks you can still validate your tests. Differencify will return `true` or `false` by the end of execution. This could be used to assert on. look at the [example](https://github.com/NimaSoroush/differencify#validate-your-changes)
116154

@@ -159,7 +197,8 @@ See [API.md](API.md) for full list of API calls
159197
|---------|----|--------|-----------|-------|
160198
|`debug`|`boolean`|no|Enables console output|false|
161199
|`imageSnapshotPath`|`string`|no|Stores reference screenshots in this directory|./differencify_reports|
162-
|`saveDifferencifiedImage`|`boolean`|no|Save differencified image to testReportPath in case of mismatch|true|
200+
|`saveDifferencifiedImage`|`boolean`|no|Save differencified image to test report path in case of mismatch|true|
201+
|`saveCurrentImage`|`boolean`|no|Save the captured image from current test run to test report path|true|
163202
|`mismatchThreshold`|`integer`|no|Difference tolerance between reference/test image|0.001|
164203

165204
## TestOptions

images/differencify-report.png

139 KB
Loading

0 commit comments

Comments
 (0)