@@ -12,18 +12,31 @@ module.exports = webDriver =>
1212
1313 const screenshot = await takeStabilizedScreenshot ( webDriver ) ;
1414
15- expect ( screenshot ) . toMatchImageSnapshot (
16- mode === 'local'
17- ? {
18- customDiffDir : testRoot ,
19- customSnapshotIdentifier : ( { counter, testPath } ) => `${ relative ( testRoot , testPath ) } .snap-${ counter } ` ,
20- customSnapshotsDir : testRoot
15+ try {
16+ expect ( screenshot ) . toMatchImageSnapshot (
17+ mode === 'local'
18+ ? {
19+ customDiffDir : testRoot ,
20+ customSnapshotIdentifier : ( { counter, testPath } ) => `${ relative ( testRoot , testPath ) } .snap-${ counter } ` ,
21+ customSnapshotsDir : testRoot
22+ }
23+ : {
24+ // jest-image-snapshot does not support <rootDir>.
25+ customSnapshotsDir : join ( __dirname , '../../../../../../../__tests__/__image_snapshots__/html/' )
26+ }
27+ ) ;
28+ } catch ( error ) {
29+ // Hidden variable to fail the test.
30+ if ( ! ( '__snapshotfail__' in webDriver ) ) {
31+ Object . defineProperty ( webDriver , '__snapshotfail__' , {
32+ configurable : false ,
33+ enumerable : true ,
34+ get ( ) {
35+ return error . message ;
2136 }
22- : {
23- // jest-image-snapshot does not support <rootDir>.
24- customSnapshotsDir : join ( __dirname , '../../../../../../../__tests__/__image_snapshots__/html/' )
25- }
26- ) ;
37+ } ) ;
38+ }
39+ }
2740
2841 if ( ! options ?. skipCheckAccessibility ) {
2942 await checkAccessibilty ( webDriver ) ( ) ;
0 commit comments