Import function in unit test file

unit-testing

#1

hi
how to import function set in app.js called fetchUrlData()
i make an export,

module.exports = {
  app,
  getCurrentDateFormat
};

but on test.js file,

TypeError: getCurrentDateFormat is not a function


#2

solved by import app side


#3

could you please clarify?


#4

the the steps I do for unit test

in app.js export function need tested

module.exports = {
  app,
  getCurrentDateFormat,
  fetchUrlData
};

in test/mytest.test.js , we need import

const {
  getCurrentDateFormat,
  fetchUrlData
} = require('../src/app');

so, launch jest

and we have message display

config.js missing in root dir

so i add empty config.js