@@ -9,15 +9,16 @@ import * as diff from "diff"
9
9
export function chars (
10
10
actual : string ,
11
11
expected : string ,
12
- message = "mismatching strings"
12
+ message = "mismatching strings" ,
13
+ options ?: diff . BaseOptions
13
14
) {
14
15
if ( actual == null ) {
15
16
throw new Error ( "AssertNoDiff: actual value not provided" )
16
17
}
17
18
if ( expected == null ) {
18
19
throw new Error ( "AssertNoDiff: expected value not provided" )
19
20
}
20
- const differences = diff . diffChars ( expected , actual )
21
+ const differences = diff . diffChars ( expected , actual , options )
21
22
if ( differences . length > 1 ) {
22
23
throw new Error ( `${ message } :\n\n${ renderDiff ( differences ) } ` )
23
24
}
@@ -30,17 +31,18 @@ export function chars(
30
31
* @throws a bash-colored error if the arguments are not equal
31
32
*/
32
33
export function json (
33
- actual : Record < string , unknown > | string [ ] ,
34
- expected : Record < string , unknown > | string [ ] ,
35
- message = "mismatching objects"
34
+ actual : object | string ,
35
+ expected : object | string ,
36
+ message = "mismatching objects" ,
37
+ options ?: diff . JsonOptions
36
38
) {
37
39
if ( ! actual ) {
38
40
throw new Error ( "AssertNoDiff: actual value not provided" )
39
41
}
40
42
if ( ! expected ) {
41
43
throw new Error ( "AssertNoDiff: expected value not provided" )
42
44
}
43
- const differences = diff . diffJson ( expected , actual )
45
+ const differences = diff . diffJson ( expected , actual , options )
44
46
if ( differences . length > 1 ) {
45
47
throw new Error ( `${ message } :\n\n${ renderDiff ( differences ) } ` )
46
48
}
@@ -55,15 +57,16 @@ export function json(
55
57
export function trimmedLines (
56
58
actual : string ,
57
59
expected : string ,
58
- message = "mismatching lines"
60
+ message = "mismatching lines" ,
61
+ options ?: diff . LinesOptions
59
62
) {
60
63
if ( actual == null ) {
61
64
throw new Error ( "AssertNoDiff: actual value not provided" )
62
65
}
63
66
if ( expected == null ) {
64
67
throw new Error ( "AssertNoDiff: expected value not provided" )
65
68
}
66
- const differences = diff . diffTrimmedLines ( expected , actual )
69
+ const differences = diff . diffTrimmedLines ( expected , actual , options )
67
70
if ( differences . length > 1 ) {
68
71
throw new Error ( `${ message } :\n\n${ renderDiff ( differences ) } ` )
69
72
}
@@ -78,15 +81,16 @@ export function trimmedLines(
78
81
export function wordsWithSpace (
79
82
actual : string ,
80
83
expected : string ,
81
- message = "mismatching words"
84
+ message = "mismatching words" ,
85
+ options ?: diff . WordsOptions
82
86
) {
83
87
if ( actual == null ) {
84
88
throw new Error ( "AssertNoDiff: actual value not provided" )
85
89
}
86
90
if ( expected == null ) {
87
91
throw new Error ( "AssertNoDiff: expected value not provided" )
88
92
}
89
- const differences = diff . diffWordsWithSpace ( expected , actual )
93
+ const differences = diff . diffWordsWithSpace ( expected , actual , options )
90
94
if ( differences . length > 1 ) {
91
95
throw new Error ( `${ message } :\n\n${ renderDiff ( differences ) } ` )
92
96
}
0 commit comments