In a project, I'm handling a service written in C#, that when called, will return a generated Javascript function. Think of it like this, but more complex:
string GetJSFunction(int value) {
return "function my_js_function() { return " + value.ToString() + "; }"
}
I want to do unit tests (in C#) to check that the methods I'm generating are valid JS code and behave correctly. Are there any "simple" way to do this? I've thought of doing the following:
- write the JS function to a temporary html page
- use a headless browser to call the webpage, call the JS script
- parse and check the result
Is there a simpler way?