I am using Mocha framework to run tests with chai assertions. I have a bit unusual architecture for it tho. I have Node.js server where I am using dockerode npm package to dynamically create docker containers upon server receiving POST request to some endpoint. and when this docker container gets created, I am passing code that needs to be tested as well as tests to this container via environment variables.
I know I can write this code and tests into files and have Mocha execute those files inside the container, but that will affect my performance. So I am wondering if there is a solution to have Mocha run these tests directly out of the environment variables, which are essentially strings?
Any advice on this would be greatly appreciated.
P.S. This architecture was implemented to allow parallel fast test execution. I have a unique scenario where any single time our service can receive hundreds of functions that need to be tested, and upon receiving a function server creates a separate container to execute tests on this function inside this container.