Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the HTML of ASP.NET MVC 3 page into a QUnit test? [duplicate]

I've started using QUnit for testing the jQuery code of a certain page in my ASP.NET MVC3 application. So far I've provided a HTML-mock which the javascript-file under test uses. Is it possible to have it referencing the actual HTML for the page used by the application instead?

like image 792
Christian Avatar asked Dec 30 '11 10:12

Christian


1 Answers

From what I can see you are trying to pre-render the HTML from the server, and run your unit-tests off of that. I dont beleive that is a great way to do this, and run your JS on that in correct sequence. Your best bet is to create a standard HTML page (not a view page), save it in your scripts folder, and use that as your "test" page. You should not rely on any standard HTML to run your Unit Tests, for the dom can be altered at any time, instead, in your unit tests handle all dom manipulation then run your assert, then remove it if it passes to maximize efficiency. You should be able to create a test environment on the dom, test it, then whipe it, rinse and repeat.

like image 158
Ryan Avatar answered Sep 28 '22 07:09

Ryan