File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ module.exports = function (config) {
99
99
try {
100
100
if ( options . reportDir ) {
101
101
fileName = path . join ( options . reportDir , fileName ) ;
102
- const mochaReportDir = path . join ( process . cwd ( ) , options . reportDir ) ;
102
+ const mochaReportDir = path . resolve ( process . cwd ( ) , options . reportDir ) ;
103
103
if ( ! fileExists ( mochaReportDir ) ) {
104
104
fs . mkdirSync ( mochaReportDir ) ;
105
105
}
Original file line number Diff line number Diff line change @@ -270,13 +270,17 @@ module.exports.deleteDir = function (dir_path) {
270
270
}
271
271
} ;
272
272
273
+ /**
274
+ * Returns absolute filename to save screenshot.
275
+ * @param fileName {string} - filename.
276
+ */
273
277
module . exports . screenshotOutputFolder = function ( fileName ) {
274
278
const fileSep = path . sep ;
275
279
276
280
if ( ! fileName . includes ( fileSep ) || fileName . includes ( 'record_' ) ) {
277
281
return path . join ( global . output_dir , fileName ) ;
278
282
}
279
- return path . join ( global . codecept_dir , fileName ) ;
283
+ return path . resolve ( global . codecept_dir , fileName ) ;
280
284
} ;
281
285
282
286
module . exports . beautify = function ( code ) {
Original file line number Diff line number Diff line change @@ -286,4 +286,32 @@ describe('utils', () => {
286
286
os . platform . restore ( ) ;
287
287
} ) ;
288
288
} ) ;
289
+
290
+ describe ( '#screenshotOutputFolder' , ( ) => {
291
+ let _oldGlobalOutputDir ;
292
+ let _oldGlobalCodeceptDir ;
293
+
294
+ before ( ( ) => {
295
+ _oldGlobalOutputDir = global . output_dir ;
296
+ _oldGlobalCodeceptDir = global . codecept_dir ;
297
+
298
+ global . output_dir = '/Users/someuser/workbase/project1/test_output' ;
299
+ global . codecept_dir = '/Users/someuser/workbase/project1/tests/e2e' ;
300
+ } ) ;
301
+
302
+ after ( ( ) => {
303
+ global . output_dir = _oldGlobalOutputDir ;
304
+ global . codecept_dir = _oldGlobalCodeceptDir ;
305
+ } ) ;
306
+
307
+ it ( 'returns the joined filename for filename only' , ( ) => {
308
+ const _path = utils . screenshotOutputFolder ( 'screenshot1.failed.png' ) ;
309
+ _path . should . eql ( '/Users/someuser/workbase/project1/test_output/screenshot1.failed.png' ) ;
310
+ } ) ;
311
+
312
+ it ( 'returns the given filename for absolute one' , ( ) => {
313
+ const _path = utils . screenshotOutputFolder ( '/Users/someuser/workbase/project1/test_output/screenshot1.failed.png' ) ;
314
+ _path . should . eql ( '/Users/someuser/workbase/project1/test_output/screenshot1.failed.png' ) ;
315
+ } ) ;
316
+ } ) ;
289
317
} ) ;
You can’t perform that action at this time.
0 commit comments