Skip to content

Instantly share code, notes, and snippets.

@jhiemer
Last active Dec 12, 2015
Embed
What would you like to do?
Testacular Configuration for AngularJS in usage with require.js
'use strict';
require.config({
paths: {
underscore: '../libs/underscore/underscore',
angular: '../libs/angular/angular.min',
angularResource: '../libs/angular/angular-resource.min',
angularCookies: '../libs/angular/angular-cookies.min',
text: '../libs/require/text',
moment: '../libs/moment/moment.min',
},
shim: {
'angular' : {'exports' : 'angular'},
'angular-resource' : {deps:['angular']},
'underscore': {exports: '_'}
},
priority: [
"angular"
],
urlArgs: 'v=0.1'
});
require([
'angular',
'angularResource',
'angularCookies',
'moment',
'app',
'routes',
etc...
], function(angular, app) {
angular.element(document).ready(function () {
angular.bootstrap(document, ['myApp']);
});
});
(function (window, require) {
"use strict";
var file, requireModules;
requireModules = [];
for (file in window.__testacular__.files) {
if (window.__testacular__.files.hasOwnProperty(file)) {
if (file.substring(file.length - 7, file.length) === 'Spec.js') {
requireModules.push(file);
}
}
}
requireModules.push("app");
requireModules.push("mocks");
require({
baseUrl:'/base/app/js',
paths:{
'angular':'../libs/angular/angular',
'mocks':'../../test/libs/angular/angular-mocks'
},
shim:{
'angular' : {'exports' : 'angular'},
'mocks':{ deps:['angular'], exports:'mocks' }
}
}, requireModules, function () {
console.log("Trying to start Testacular");
window.__testacular__.start();
}, function (err) {
console.log(err);
});
}(window, require));
-app
-js
- controller
- directives
- ...
- app.js
- main.js
- routes.js
-libs
- angular
- require
-scripts
-test.sh
-test
- libs
- angular
- unit
...
basePath = '../';
files = [
JASMINE,
JASMINE_ADAPTER,
REQUIRE,
REQUIRE_ADAPTER,
{pattern:'app/libs/angular/angular.js', included:false},
{pattern:'test/libs/angular/angular-mocks.js', included:false},
{pattern:'app/js/**/*', included:false}, //Produktionscode
{pattern:'test/unit/**/*.js', included:false}, //Testcode
'test/main-test.js' //requireJS-Konfiguration
];
autoWatch = true;
browsers = ['Chrome'];
junitReporter = {
outputFile: 'test_out/unit.xml',
suite: 'unit'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment