From 0a83f543b5960a932e8711a3fe5085ef2b43b55c Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 19 Oct 2024 17:28:16 +0530 Subject: [PATCH] fegwg --- tests/build-tools.test.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index 7be2e5148e8..c4feff26227 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -3,6 +3,7 @@ const { resolve } = require('path'); const { buildTools } = require('../scripts/build-tools'); const { tagsData, manualTools, mockConvertedData, mockExtractData } = require('../tests/fixtures/buildToolsData'); const fs = require('fs'); +const { beforeEach, afterEach } = require('node:test'); jest.mock('axios'); jest.mock('../scripts/tools/categorylist', () => ({ @@ -29,15 +30,17 @@ describe('buildTools', () => { const tagsPath = resolve(testDir, 'all-tags.json'); const automatedToolsPath = resolve(testDir, 'tools-automated.json'); const manualToolsPath = resolve(testDir, 'tools-manual.json'); + + if (!fs.existsSync(testDir)) { + fs.mkdirSync(testDir, { recursive: true }); + } + if (!fs.existsSync(manualToolsPath)) { + fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools)); + } + let consoleErrorMock; beforeAll(() => { - if (!fs.existsSync(testDir)) { - fs.mkdirSync(testDir, { recursive: true }); - } - if (!fs.existsSync(manualToolsPath)) { - fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools)); - } consoleErrorMock = jest.spyOn(console, 'error').mockImplementation(() => {}); }); @@ -50,6 +53,10 @@ describe('buildTools', () => { beforeEach(() => { jest.clearAllMocks(); + + if (!fs.existsSync(manualToolsPath)) { + fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools)); + } }); it('should extract, convert, combine tools, and write to file', async () => {