You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jest-diff: Add includeChangeCounts and rename Indicator options (#8881)
* jest-diff: Add includeChangeCounts option
* Update CHANGELOG.md
* Rename Symbol options as Indicator like git diff
* Display indicator following change counts
* Update the example diff in README.md
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
-`[jest-config]`[**BREAKING**] Set default display name color based on runner ([#8689](https://github.com/facebook/jest/pull/8689))
7
7
-`[jest-diff]` Add options for colors and symbols ([#8841](https://github.com/facebook/jest/pull/8841))
8
8
-`[jest-diff]`[**BREAKING**] Export as ECMAScript module ([#8873](https://github.com/facebook/jest/pull/8873))
9
+
-`[jest-diff]` Add `includeChangeCounts` and rename `Indicator` options ([#8881](https://github.com/facebook/jest/pull/8881))
9
10
-`[jest-runner]` Warn if a worker had to be force exited ([#8206](https://github.com/facebook/jest/pull/8206))
10
11
-`[@jest/test-result]` Create method to create empty `TestResult` ([#8867](https://github.com/facebook/jest/pull/8867))
11
12
-`[jest-worker]`[**BREAKING**] Return a promise from `end()`, resolving with the information whether workers exited gracefully ([#8206](https://github.com/facebook/jest/pull/8206))
- annotation lines: describe the two change symbols with labels, and a blank line
43
+
- annotation lines: describe the two change indicators with labels, and a blank line
44
44
- comparison lines: similar to “unified” view on GitHub, but `Expected` lines are green, `Received` lines are red, and common lines are dim (by default, see Options)
- annotation lines: describe the two change symbols with labels, and a blank line
93
+
- annotation lines: describe the two change indicators with labels, and a blank line
94
94
- comparison lines: similar to “unified” view on GitHub, and **changed substrings** have **inverted** foreground and background colors (which the following example does not show)
95
95
96
96
```diff
@@ -107,9 +107,9 @@ The returned **string** consists of:
107
107
Here are edge cases for the return value:
108
108
109
109
- both `a` and `b` are empty strings: no comparison lines
110
-
- only `a` is empty string: all comparison lines have `bColor` and `bSymbol` (see Options)
111
-
- only `b` is empty string: all comparison lines have `aColor` and `aSymbol` (see Options)
112
-
-`a` and `b` are equal non-empty strings: all comparison lines have `commonColor` and `commonSymbol` (see Options)
110
+
- only `a` is empty string: all comparison lines have `bColor` and `bIndicator` (see Options)
111
+
- only `b` is empty string: all comparison lines have `aColor` and `aIndicator` (see Options)
112
+
-`a` and `b` are equal non-empty strings: all comparison lines have `commonColor` and `commonIndicator` (see Options)
113
113
114
114
### Performance of diffStringsUnified
115
115
@@ -184,7 +184,7 @@ diffs[4][1] === 'm'
184
184
*/
185
185
```
186
186
187
-
## Advanced import for diffStringsRaw
187
+
###Advanced import for diffStringsRaw
188
188
189
189
Here are all the named imports for the `diffStringsRaw` function:
190
190
@@ -216,14 +216,15 @@ For other applications, you can provide an options object as a third argument:
216
216
| :-------------------- | :------------ |
217
217
|`aAnnotation`|`'Expected'`|
218
218
|`aColor`|`chalk.green`|
219
-
|`aSymbol`|`'-'`|
219
+
|`aIndicator`|`'-'`|
220
220
|`bAnnotation`|`'Received'`|
221
221
|`bColor`|`chalk.red`|
222
-
|`bSymbol`|`'+'`|
222
+
|`bIndicator`|`'+'`|
223
223
|`commonColor`|`chalk.dim`|
224
-
|`commonSymbol`|`' '`|
224
+
|`commonIndicator`|`' '`|
225
225
|`contextLines`|`5`|
226
226
|`expand`|`true`|
227
+
|`includeChangeCounts`|`false`|
227
228
|`omitAnnotationLines`|`false`|
228
229
229
230
### Example of options for labels
@@ -264,18 +265,18 @@ const options = {
264
265
};
265
266
```
266
267
267
-
### Example of options for symbols
268
+
### Example of options for indicators
268
269
269
-
For consistency with the `diff` command, you might replace the symbols:
270
+
For consistency with the `diff` command, you might replace the indicators:
270
271
271
272
```js
272
273
constoptions= {
273
-
aSymbol:'<',
274
-
bSymbol:'>',
274
+
aIndicator:'<',
275
+
bIndicator:'>',
275
276
};
276
277
```
277
278
278
-
The `jest-diff` package assumes (but does not enforce) that the 3 symbols have equal length.
279
+
The `jest-diff` package assumes (but does not enforce) that the 3 indicators have equal length.
279
280
280
281
### Example of options to limit common lines
281
282
@@ -292,6 +293,32 @@ const options = {
292
293
293
294
A patch mark like `@@ -12,7 +12,9 @@` accounts for omitted common lines.
294
295
296
+
### Example of option to include change counts
297
+
298
+
To display the number of change lines at the right of annotation lines:
0 commit comments