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

1

16

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?

Nordin answered 30/12, 2011 at 10:35 Comment(6)
Found the answer here: #5454381Nordin
I'd either delete this question or answer it yourself and accept your own answer then, so it's not just hanging around unanswered.Geomorphic
I did answer it myself but SO automatically turned it into a comment due to its triviality. In the case of deleting the question; what if it turns up in a search but not the answer that is linked to in the comment?Nordin
Agree with Jon, you could post the link as the answer and then accept that as the answer to close the question.Archdeacon
@cchana: unless SO has changes their policy concerning answering trivial questions my comment above is still valid. I've voted to have the question closed, you could do this too.Nordin
@Nordin I didn't even know you could do that and unfortunately, I don't have enough rep to do that anyway (which is probably why I didn't know you could do that). Thanks for mentioning it, makes more sense as to why some things are closed!Archdeacon
A
1

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.

Appreciate answered 13/9, 2013 at 18:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.