@@ -10,6 +10,7 @@ const event = require('../../../lib/event')
10
10
const recorder = require ( '../../../lib/recorder' )
11
11
const { createTest } = require ( '../../../lib/mocha/test' )
12
12
const { deserializeSuite } = require ( '../../../lib/mocha/suite' )
13
+
13
14
let screenshotSaved
14
15
15
16
describe ( 'screenshotOnFail' , ( ) => {
@@ -101,5 +102,40 @@ describe('screenshotOnFail', () => {
101
102
await recorder . promise ( )
102
103
expect ( ! screenshotSaved . called ) . is . ok
103
104
} )
105
+
106
+ it ( 'should have the same unique file name as the mochawesome helper when the uuid is present' , async ( ) => {
107
+ screenshotOnFail ( { uniqueScreenshotNames : true } )
108
+ const test = createTest ( 'test1' )
109
+ test . uid = '1234'
110
+
111
+ const MochawesomeHelper = require ( '../../../lib/helper/Mochawesome' )
112
+
113
+ const helper = new MochawesomeHelper ( { uniqueScreenshotNames : true } )
114
+ const spy = sinon . spy ( helper , '_addContext' )
115
+ helper . _failed ( test )
116
+
117
+ event . dispatcher . emit ( event . test . failed , test )
118
+ await recorder . promise ( )
119
+
120
+ const screenshotFileName = screenshotSaved . getCall ( 0 ) . args [ 0 ]
121
+ expect ( spy . getCall ( 0 ) . args [ 1 ] ) . to . equal ( screenshotFileName )
122
+ } )
123
+
124
+ it ( 'should have the same unique file name as the mochawesome helper when the uuid is not present' , async ( ) => {
125
+ screenshotOnFail ( { uniqueScreenshotNames : true } )
126
+ const test = createTest ( 'test1' )
127
+
128
+ const MochawesomeHelper = require ( '../../../lib/helper/Mochawesome' )
129
+
130
+ const helper = new MochawesomeHelper ( { uniqueScreenshotNames : true } )
131
+ const spy = sinon . spy ( helper , '_addContext' )
132
+ helper . _failed ( test )
133
+
134
+ event . dispatcher . emit ( event . test . failed , test )
135
+ await recorder . promise ( )
136
+
137
+ const screenshotFileName = screenshotSaved . getCall ( 0 ) . args [ 0 ]
138
+ expect ( spy . getCall ( 0 ) . args [ 1 ] ) . to . equal ( screenshotFileName )
139
+ } )
104
140
// TODO: write more tests for different options
105
141
} )
0 commit comments