You must add all the appropriate logic for your application to the device test file so that they all run before ..
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>QUnit Test Results</title> <link rel="stylesheet" href="/Content/qunit.css"> </head> <body> <div id="qunit"></div> <div id="qunit-fixture"></div> <script src="/Scripts/qunit.js"></script> <script src="/Scripts/PlayerSkill.js"></script> <script src="/Scripts/trainings.js"></script> <script src="/TestScripts/TrainingTests.js"></script> </body> </html>
Linked files cannot be used because they will not physically exist in the script folder.
If you really want to use them, you must allow Visual Studio intellisense to resolve the physical path to a file like this.
- Enter the tag tag
<script src=""></script> - Place the cursor inside the quotation marks in the src attribute and press
CTRL + SPACE - Search for files and allow resolved path intact
- If your project location has changed, you must update the related files as well as the script links.
{Edit1}
Solution 2:
You can also use the MVC controller and Razor View to create a device test page, and the associated files will work as expected with the only problem in which you will have an additional controller in your project, but this is not bad at all if, for example, you you want to test the loading of content using ajax, which by default is blocked by the browser if they are running from a local file.
Solution 3:
You can also set up a new MVC project only for testing your javascript module, as you usually set up a new project for any code on the server side, and this will help prevent your testing to interfere with your production code.
{Change 2}
Solution 4:
As part of the javascript ecosystem, you can use grunt or gulp to automate copying your scripts from anywhere to your project before running tests. You can write gulpfile.js, like this
var sourcefiles = []; gulp.task('default', function () { return gulp.src(sourcefiles).pipe(gulp.dest('Scripts')); });
And then run it by opening the console and running the gulp or gulp default
devconcept
source share