Saturday 30 May 2020

How to test a function that manipulates files and directories .

So I am creating a library and its project folder looks like this :project-folder ├─node_modules ├─src │ └─modules │ ├─private │ │ ├─privateFn1.ts │ │ ├─privateFn2.ts │ │ ├─ ... │ │ └─privateFnN.ts │ ├─fn1.ts │ ├─fn2.ts │ ├─ ... │ └─fnN.ts ├─package.json └─tsconfig.json Each fn*.ts default exports a single function which is intended for public usage.Each privateFn*.ts exports a single reference which is intended for private usage.I have created a module which when executed creates a file which :exports the default export of each fn*.ts with name fn*.imports nothing (i.e. the file is bundled and has no depedency).default exports an object which contains as properties all already exported functions.That module exists in its own project folder which does not contain the folder and file structure which I previously draw .1)The question is how do I test such a module ?I am completely noob on testing . I have never written a single test.2)Should I just write a test.js file which programmatically creates the folder and file structure and then programmatically tests the resulting file from the execution of the module ?3)I will be in need of deleting these folders and files afterwards because maybe I will need to rerun the test . How can I create a safe space for deletion of files and folders so I will not accidentally ?4)Is the name of such a test end to end test , but for back end ?5)Which testing frameworks do you use for node?

Submitted May 31, 2020 at 12:04AM by liaguris

No comments:

Post a Comment