vendredi 11 août 2017

Jasmine - Module isn't defined

I'm trying to test the Angular routing for the single-page-application project I'm working on, but Jasmine keeps returning 'Module isn't defined'. I've searched high and low on here for an answer, but nothing seems to work. It's bound to be something simple, but I'm very new to Jasmine and Angular, so would appreciate it if someone could point me in the right direction.

My SpecRunner:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.4.1</title>

<link rel="shortcut icon" type="image/png" href="lib/jasmine-
  2.4.1/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-2.4.1/jasmine.css">

<script src="lib/jasmine-2.4.1/jasmine.js"></script>
<script src="lib/jasmine-2.4.1/jasmine-html.js"></script>
<script src="lib/jasmine-2.4.1/boot.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="node_modules/angular-mocks/angular-mocks.js"></script>

<!-- include source files here... -->
<script src="src/app.js"></script>
<script src="src/controller.js"></script>

<!-- include spec files here... -->
<script src="spec/formSpec.js"></script>

</head>

<body>
</body>
</html>

My formSpec.js:

describe('Testing Routes', function () {

beforeEach(module('RelifeApp'));

it('Should test routes',
inject(function ($route) {

expect($route.routes['/'].controller).toBe('');
expect($route.routes['/'].templateUrl).toEqual('templates/home.html');

expect($route.routes['/about'].controller).toBe('');
expect($route.routes['/about'].templateUrl).toEqual('templates/about.html');

expect($route.routes['/faq'].controller).toBe('');
expect($route.routes['/faq'].templateUrl).toEqual('templates/faq.html');

expect($route.routes['/contact'].controller).toBe('');

expect($route.routes['/contact'].templateUrl).toEqual
('templates/contact.html');

expect($route.routes['/register'].controller).toBe
('RegistrationController');

expect($route.routes['/register'].templateUrl).toEqual
('templates/register.html');

expect($route.routes['/success'].controller).toBe('');

expect($route.routes['/success'].templateUrl).toEqual
('templates/success.html');

expect($route.routes['/fail'].controller).toBe('');
expect($route.routes['/fail'].templateUrl).toEqual('templates/fail.html');

}));

});

And my app.js:

angular.module("RelifeApp", ["ngRoute", "RouteControllers"]);

angular.module("RelifeApp").config(function($routeProvider, 
  $locationProvider) {
    $locationProvider.html5Mode(true);

$routeProvider.when("/", {
    templateUrl: "templates/home.html"

})
.when("/about", {
    templateUrl: "templates/about.html"

})
.when("/faq", {
    templateUrl: "templates/faq.html"

})
.when("/contact", {
    templateUrl: "templates/contact.html"

})
.when("/register", {
    templateUrl: "templates/register.html",
    controller: "RegistrationController"
})
.when("/fail", {
    templateUrl: "templates/fail.html"

})
.when("/success", {
    templateUrl: "templates/success.html",

})
.otherwise({
    redirectTo: "/"
});
});

Aucun commentaire:

Enregistrer un commentaire