Issue with export in Nodejs

37 Views Asked by At

I am running some test scripts. I am using csvtoparse to convert the csv file into json and i am attempting to export the object sets using module.exports. My code is shown below:

const csv = require('csvtojson');

async function getData(){
    const jsonArray=await csv().fromFile('./test1.csv');
    return jsonArray;
}
module.exports = {
    getData: getData
}

However, I am getting this error in my terminal

  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "[
      {
        TESTCASE_ID: '1',
        BROWSER_TYPE: 'chromium',
        BASE_URL: 'https://css-tricks.com/'
      },
      {
        TESTCASE_ID: '2',
        BROWSER_TYPE: 'chromium',
        BASE_URL: 'https://css-tricks.com/'
      }
    ]".

Is there a way to iterate through the csv and export each json object in nodejs?

0

There are 0 best solutions below