I have file index with anonymous function or IIFE like this below
(async()=> todo list logic)()
I want to call this anonymous function on my test case, is there any way to run this anonymous func on my unit test case? or is there any way to call this function using typescript code?
thanks in advance
No, you can not call it explicitly from your tests. I recommend creating a pure function and an additional IFFE wrapper. This way you can import your pure function into your tests.
// foo.js
function foo() {}
export default foo
// foo-wrapper.js
(() => {
foo()
})()
// foo.test.js
import foo from './foo.js'