yearofmoo-articles / AngularJS-Testing-Article

A testing repository for AngularJS
263 stars 111 forks source link

Issue converting from Jasmine to Mocha / Chai #1

Closed chriscantu closed 11 years ago

chriscantu commented 11 years ago

Hello, I really enjoyed your article on Full Spectrum Testing on Angular. I am attempting to convert my Jasmine based testing to Mocha/Chai based on your example.

I have updated my configuration and modelled it after yours. I believe I have gotten all of the required dependencies but I am consistently getting the following error.

TypeError: 'undefined' is not a function (evaluating 'angular.mock.module('one')')

Here is the code its erroring on

beforeEach(angular.mock.module('one'));

('one' is the name of my application.)

I am sure its something I am overlooking. Any help you could provided would be greatly appreciated. I am hoping your recognize the error otherwise, I can post my config file if and several snippets from my test.

Many thanks in advance.

Chris

matsko commented 11 years ago

This is because of the angular-mocks.js file. Turns out that the one provided in Angular-Seed and in the AngularJS download does not include support for mocha. I had to download it directly from their github repo. So if you use the file from this testing repository then it should work. Be sure to also include it into the testacular configuration just after you include angularjs.

https://github.com/yearofmoo-articles/AngularJS-Testing-Article/blob/master/test/lib/angular/angular-mocks.js#L1590

chriscantu commented 11 years ago

That seemed to do the trick. Muchas Gracias!!!