Online compiler with testing feature
Asked by langesh about 6 months ago
I have build a simple online nodejs compiler that will get a program from user and store it into a file. Then I used exec(file_name,(err,stdout,stderr) => {...}. It will compile the file and check for errors. Then how can I test the code using vitest or some other testing frameworks.
1 Answer
- An environment to run the code (compute instance running nodejs - local, AWS, GCP, DO, etc)
- Automated test suites (.spec files using cypress, playwright or vitest)
- Some configuration to study the test results (could be fully custom / provided by the testing framework)
I have created the test cases with vitest. My question is how can I test the user's program with than tese case. And it will return the status of all the test case.
To test any code, you'll require:
Now in your case of the Nodejs compiler, you can run unit tests on the source code of your Nodejs compiler locally. Learn more through this course.
If you want to test the code users are entering into your Nodejs compiler, you'll have to input custom test cases from them and run those tests against their code in a remote compute instance.
I have created the test cases with vitest. My question is how can I test the user's program with than tese case. And it will return the status of all the test case.