Попытка запустить мой тест на жасмин для моего углового фильтра. Это то, что фильтр выглядит следующим образом:Как создать модуль для модульного тестирования?
(function() {
'use strict';
var app = angular.module('mymodule');
app.filter('customCurrency', function($filter) {
return function(amount, currencySymbol, fractionSize) {
var currency = $filter('currency');
if (amount < 0) {
return currency(amount, currencySymbol).replace('(', '-').replace(')', '');
}
..
Так я определил его в MyModule и это то, что тестовый модуль выглядит следующим образом:
describe('custom currency Filter', function() {
var myUpperFilter, $filter;
beforeEach(function() {
module('mymodule');
inject(function($injector) {
// Append Filter to the filter name
// Usign $filter Provider
$filter = $injector.get('$filter');
});
});
it('if I have 2 zeros in decimals only display max of 2 zeros in decimals', function() {
// using $filter
expect($filter('customCurrency')(1.0011, '$', undefined)).toEqual('$1<span class="decimals">.00</span>');
});
})
Однако получить эту ошибку при выполнении теста:
Error: [$injector:modulerr] Failed to instantiate module mymodule due to:
Error: [$injector:nomod] Module 'mymodule' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Обновление: Я на самом деле есть ситуация с основным модулем и зависимую:
var app = angular.module('plunker', ['ngRoute','mymodule']);
var app2 = angular.module('mymodule');
измененная plunkr:
http://plnkr.co/edit/Rcu5gojIJG1GSZEhU4sZ?p=preview