The context is that I need to read the data from local memory instead of a database. I want to switch to a different memory object when I am testing. To achieve this, my plan is for my function that fetches the data to check the NODE_ENV, if it is "test", then import the data from directory A, else directory B.
However, doing if/else then import throws SyntaxError of unexpected identifier. Is there some way to do conditional import in NodeJS, or a more elegant way to achieve my purpose in general?