4

For unit testing purposes: Im searching for testing framework like NUnit that can validate if a "javascript" is valid within the most common browsers (IE, FF, Chrome, Safari). The javascript will be automaticly created from an class.

Does someone know if there is a testing framework like NUnit for this, within cscharp (c#)? Ofcourse Im writing tests myself on the javascript so it should be good.

But I just want to be absolutly sure its valid.

6
  • unless your writing an X to JS compiler, generating JavaScript seems like a bad thing to do. Commented Aug 21, 2011 at 18:32
  • How complex is the generated javascript? What kind of verification do you need (apart from valid syntax)? Commented Aug 21, 2011 at 18:32
  • Its for an html helper, only the valid syntax should be fine. Commented Aug 21, 2011 at 18:34
  • @Raynos, why would it be a bad thing? See this post by Scott Hanselman Commented Aug 21, 2011 at 18:35
  • @ThomasLevesque as mentioned writing a full compiler to create this JS is valid. However using string concatenation, templates or some other naive method to generate JS is bad. Commented Aug 21, 2011 at 18:38

3 Answers 3

1

This looks useful: http://madskristensen.net/post/Verify-JavaScript-syntax-using-C.aspx

Sign up to request clarification or add additional context in comments.

Comments

1

Get a modified copy of jshint and run your generated code through to check whether it's correct. I'd probably use JS.NET 2010 for this or ironJS.

Comments

0

I would suggest using Selenium to actually run the Javascript in the supported browsers. It is easily used from any xUnit type testing framework and it supported by C#.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.