@@ -9,10 +9,7 @@ import { modifyJsonFile, modifyPackageJsonFile } from "../build/";
99
1010const jsonFilePath = path . join ( __dirname , "testing-file.json" ) ;
1111
12- // that's fine until tests are running with --serial flag
13- let dataToWrite ;
14-
15- test . beforeEach ( async ( ) => {
12+ const prepare = async ( dataToWrite ?) => {
1613 await jsonfile . writeFile ( jsonFilePath , dataToWrite ?? {
1714 "name" : "package" ,
1815 "main" : "index.js" ,
@@ -22,13 +19,14 @@ test.beforeEach(async () => {
2219 "fdir" : ">=2"
2320 }
2421 } , { spaces : 4 } ) ;
25- } ) ;
22+ } ;
2623
2724test . afterEach . always ( async ( ) => {
2825 await del ( jsonFilePath ) ;
2926} ) ;
3027
3128test ( "modifies JSON file" , async t => {
29+ await prepare ( ) ;
3230 await modifyJsonFile ( jsonFilePath , {
3331 name : s => `super ${ s } ` ,
3432 main : "build/electron.js" ,
@@ -41,6 +39,7 @@ test("modifies JSON file", async t => {
4139} ) ;
4240
4341test ( "modifies package.json file with async function" , async t => {
42+ await prepare ( ) ;
4443 await modifyPackageJsonFile ( jsonFilePath , async ( { main } ) => {
4544 return { types : main , name : "ahaha" } ;
4645 } ) ;
@@ -49,8 +48,8 @@ test("modifies package.json file with async function", async t => {
4948} ) ;
5049
5150test ( "modifies package.json file which has numeric type" , async t => {
52- dataToWrite = 50 ;
53- await modifyPackageJsonFile ( jsonFilePath , n => n + 5 ) ;
51+ await prepare ( 50 ) ;
52+ await modifyJsonFile < number > ( jsonFilePath , n => n + 5 ) ;
5453 const modifiedJsonFle = await fs . readFile ( jsonFilePath , "utf8" ) ;
5554 t . snapshot ( modifiedJsonFle ) ;
5655} ) ;
0 commit comments