How to Test User Submitted code Just like free code camp

Hi guys , My name is Sam, and I am currently banging my head out of frustration, so I started working on a project that teaches HTML, CSS ,js interactively because of my friends that kept asking to teach coding, I am using react for frontend , I want to be able to test the code users submit but right now I don’t even know how to go about it, I am so frustrated right now… Please any help

you could explore how freecodecamp does it, it’s an open source project so the code is openly visible (and people can contribute to it!)

Speaking broadly, tests do two things - check for errors and check for correctness. With tests, especially for a learning application, you really wouldn’t want to check for literal character for character matching against ‘good’ code.

  1. Check for Errors:
    I am in the world of C. My test suite checks for segfaults and other runtime errors. I imagine, but probably the webdev experts can chime in, that you can do something similar with HTML, CSS, Javascript testing.

  2. Check for Correctness:
    In this case, I run the user provided code against a set of inputs designed to look for common logic errors. I have a file that has the true results so I can compare user results against truth.

I know codeacademy has some content on writing tests for webdev, but not being a webdev guy myself, I can’t vouch for it.

I think ultimately it would be a good idea to look at some open source products to see how they do it - digging through GitHub repos is daunting but it’s far better than reinventing the wheel.

Good luck! Your project sounds cool.

1 Like

Thanks Bob, yea I started digging through the free code camp repo, but you know what they say reading some else’s code is a pain in the Butt hahahahaha, I would keep looking for answers

I think this is where they have the most comprehensive discussion of writing new tests, though I didn’t see where the implementation of the testing is.