File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,10 @@ class Mochawesome extends Helper {
5151      fileName  =  clearString ( `${ test . title } ${ currentTest . test . title }  ) 
5252    }  else  { 
5353      currentTest  =  {  test } 
54-       fileName  =  ` ${ testToFileName ( test ) } ` 
54+       fileName  =  testToFileName ( test ) 
5555    } 
5656    if  ( this . options . uniqueScreenshotNames )  { 
57-       const  uuid  =  test . uuid  ||  test . ctx . test . uuid 
58-       fileName  =  `${ fileName . substring ( 0 ,  10 ) } ${ uuid }  
57+       fileName  =  testToFileName ( test ,  {  unique : true  } ) 
5958    } 
6059    if  ( test . _retries  <  1  ||  test . _retries  ===  test . retryNum )  { 
6160      fileName  =  `${ fileName }  
Original file line number Diff line number Diff line change @@ -135,9 +135,19 @@ function cloneTest(test) {
135135  return  deserializeTest ( serializeTest ( test ) ) 
136136} 
137137
138- function  testToFileName ( test ,  suffix  =  '' )  { 
138+ /** 
139+  * Get a filename from the test object 
140+  * @param  {CodeceptJS.Test } test 
141+  * @param  {Object }  options 
142+  * @param  {string }  options.suffix Add a suffix to the filename 
143+  * @param  {boolean } options.unique Add a unique suffix to the file 
144+  * 
145+  * @returns  {string } the filename 
146+  */ 
147+ function  testToFileName ( test ,  {  suffix =  '' ,  unique =  false  }  =  { } )  { 
139148  let  fileName  =  test . title 
140149
150+   if  ( unique )  fileName  +=  `_${ test ?. uid  ||  Math . floor ( new  Date ( ) . getTime ( )  /  1000 ) }  
141151  if  ( suffix )  fileName  =  `${ fileName } ${ suffix }  
142152  // remove tags with empty string (disable for now) 
143153  // fileName = fileName.replace(/\@\w+/g, '') 
@@ -151,6 +161,7 @@ function testToFileName(test, suffix = '') {
151161  //   fileName = `${clearString(test.parent.title)}_${fileName}` 
152162  // } 
153163  fileName  =  clearString ( fileName ) . slice ( 0 ,  100 ) 
164+ 
154165  return  fileName 
155166} 
156167
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ module.exports = function (config) {
8686        let  fileName 
8787
8888        if  ( options . uniqueScreenshotNames  &&  test )  { 
89-           fileName  =  `${ testToFileName ( test ,  _getUUID ( test ) ) }  
89+           fileName  =  `${ testToFileName ( test ,  {   unique :  true   } ) }  
9090        }  else  { 
9191          fileName  =  `${ testToFileName ( test ) }  
9292        } 
@@ -137,12 +137,4 @@ module.exports = function (config) {
137137      true , 
138138    ) 
139139  } ) 
140- 
141-   function  _getUUID ( test )  { 
142-     if  ( test . uid )  { 
143-       return  test . uid 
144-     } 
145- 
146-     return  Math . floor ( new  Date ( ) . getTime ( )  /  1000 ) 
147-   } 
148140} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments