@@ -32,7 +32,7 @@ async function getScreenshots(dir) {
32
32
33
33
async function compareSnapshot (
34
34
snapshotName ,
35
- { referenceDir, testDir, outputDir }
35
+ { referenceDir, testDir, outputDir, threshold }
36
36
) {
37
37
console . log ( `Comparing screenshot ${ snapshotName } ` )
38
38
@@ -45,21 +45,26 @@ async function compareSnapshot(
45
45
) ,
46
46
imageOutputLimit : PixelDiff . OUTPUT_SIMILAR ,
47
47
thresholdType : PixelDiff . THRESHOLD_PERCENT ,
48
- threshold : 0.01 , // 1% threshold
48
+ threshold : threshold ,
49
49
} )
50
50
51
51
return diff . runWithPromise ( )
52
52
}
53
53
54
- async function command ( { referenceDir, testDir, outputDir, max } ) {
54
+ async function command ( { referenceDir, testDir, outputDir, max, threshold } ) {
55
55
await ensureScreenshotsDir ( outputDir )
56
56
57
57
const snapshots = await getScreenshots ( referenceDir )
58
58
59
59
console . log ( 'Starting tests...\n' )
60
60
61
61
for ( let snapshotName of snapshots . slice ( 0 , max ) ) {
62
- await compareSnapshot ( snapshotName , { referenceDir, testDir, outputDir } )
62
+ await compareSnapshot ( snapshotName , {
63
+ referenceDir,
64
+ testDir,
65
+ outputDir,
66
+ threshold,
67
+ } )
63
68
}
64
69
}
65
70
0 commit comments