I recently installed Chutzpah in order to execute Jasmine-based unit tests for Javascript. This is my first experience with both Jasmine, Chutzpah, and Angular. I have created a test file for an angular filter called filters.spec.js which contains the code below:
/// <reference path="c:\users\octaviane.cvuintelligence\documents\visual studio 2013\Projects\PersonalTrainer\PersonalTrainer\Scripts/jasmine.js" />
/// <reference path="c:\users\octaviane.cvuintelligence\documents\visual studio 2013\Projects\PersonalTrainer\PersonalTrainer\Scripts/angular.js" />
/// <reference path="../app.js" />
describe("Filters", function () {
beforeEach(function () { module('7minWorkout') });
describe("secondsToTime filter", function () {
it('should convert integer to time format',
inject(function ($filter) {
expect($filter("secondsToTime")(5)).toBe("00:00:05");
expect($filter("secondsToTime")(65)).toBe("00:01:05");
expect($filter("secondsToTime")(3610))
.toBe("01:00:10");
}));
});
});
In this code snippet, I've referenced angular.js, jasmine.js, and the JavaScript file where the 7minWorkout module is defined. As a beginner, I kindly ask for your patience in case of any mistakes. However, when attempting to run the test file (by right-clicking on the file contents in Visual Studio and selecting 'Run JS Tests'), I encounter the following errors: Can't find variable: module and Can't find variable: inject. Any assistance would be greatly appreciated. Thank you.