@@ -11,7 +11,6 @@ const {
11
11
getRelatedTestImports,
12
12
getSourceCodeFromAst,
13
13
getModuleTypeFromFilePath,
14
- rearrangeImportsInCode,
15
14
replaceRequirePaths
16
15
} = require ( "../utils/code" ) ;
17
16
const { getFunctionsForExport } = require ( "./unitTests" ) ;
@@ -35,15 +34,13 @@ let functionList = {},
35
34
ignoreErrors = [ "BABEL_PARSER_SYNTAX_ERROR" ] ,
36
35
force ;
37
36
38
- async function saveTests ( filePath , fileName , originalTests , newTests ) {
37
+ async function saveTests ( filePath , fileName , newTests ) {
39
38
let dir = filePath . substring ( 0 , filePath . lastIndexOf ( "/" ) ) ;
40
39
if ( ! await checkDirectoryExists ( dir ) ) {
41
40
fs . mkdirSync ( dir , { recursive : true } ) ;
42
41
}
43
42
let testPath = path . join ( dir , `/${ fileName } ` ) ;
44
- let mergedTestCode = `${ originalTests . trim ( ) } \n\n${ newTests . trim ( ) } ` ;
45
- mergedTestCode = rearrangeImportsInCode ( mergedTestCode ) ;
46
- fs . writeFileSync ( testPath , mergedTestCode ) ;
43
+ fs . writeFileSync ( testPath , newTests ) ;
47
44
return testPath ;
48
45
}
49
46
@@ -130,7 +127,7 @@ async function createAdditionalTests(filePath, prefix) {
130
127
} ) ;
131
128
132
129
if ( tests ) {
133
- await saveTests ( testPath , formattedData . testFileName , testCode , tests ) ;
130
+ await saveTests ( testPath , formattedData . testFileName , tests ) ;
134
131
testsGenerated . push ( testPath ) ;
135
132
await spinner . stop ( ) ;
136
133
folderStructureTree [
0 commit comments