After reading about unit testing javascript / bdd in VS, I found that you can use a combination:
- ReSharper - support for PhantomJS headless + Jasmine/QUnit - Testr - mock Require dependencies
I used Jasmine in a test script and was able to successfully run some simple tests with functions declared in the same file.
However, I could not find / build the working end to the end for testing the js module with dependencies. I am trying to use the example used in the John Pap Jumpstart spa example.
Therefore, the module view.mod.js is specified, which has a dependency on datacontext.js:
define(['services/datacontext'], function (datacontext) { var peopleViewModel = { title: 'People page' }; return peopleViewModel; })
Folder structure:
/App/Viewmodels : people.js /App/Services : datacontext.js /App/Tests : peopletests.js
What do I need to add to the peopletests.js file to run this test?
describe("My Tests Set", function () { it("People Title Test", function () { expect(peopleViewModel.title()).toEqual("People page"); }); });
source share