After reading about javascript unit testing / bdd in VS I found that you could use a combination of:
- 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 a working end to end example for testing a js module with dependencies. I am trying to build on the example used in the SPA Jumpstart example by John Papa.
So given a people.js viewmodel module that has a dependency in 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 in a peopletests.js to make this test run?
describe("My Tests Set", function () {
it("People Title Test", function () {
expect(peopleViewModel.title()).toEqual("People page");
});
});