I have a function that extracts data from files and returns it in an array
const extractTestCases = () => {
const filesArray = []
const filterTestSuite = files.filter(test => test.includes('.test.ts'))
filterTestSuite.forEach(testsuite => {
const feature = regexMatcher(testsuite, featureRegex, 1)
const testSuites = fs.readFileSync(testsuite, { encoding: "utf8" });
const testCases = regexMatcher(testSuites, TestRegex, 1)
filesArray.push({ [feature]: testCases })
})
return filesArray;
}
This currently gives me an output like the following
[
{
featureCustom: [ 'somethig' ]
},
{
featureInsp: [
'bla bla',
'foo foo'
]
}
]
I want to modify it to generate an output like this
[
{
"features": [
{
"featureCustom": [ 'somethig'
]
},
{
"featureInsp": ['bla bla','foo foo'
]
}
]
}
]