Abbiamo finito per mettere i test e dati falsi sotto la cartella spec
dell'app di Rails e configurare Karma per importarli così come i nostri testati codice da app/assets
.
Lavora per noi. Altre idee sono benvenute.
nostro config/karma.conf.js
di file:
basePath = '../';
files = [
JASMINE,
JASMINE_ADAPTER,
//libs
'vendor/assets/javascripts/angular/angular.js',
'vendor/assets/javascripts/angular/angular-*.js',
'vendor/assets/javascripts/jquery-1.9.1.min.js',
'vendor/assets/javascripts/underscore-min.js',
'vendor/assets/javascripts/angular-strap/angular-strap.min.js',
'vendor/assets/javascripts/angular-ui/angular-ui.js',
'vendor/assets/javascripts/angular-bootstrap/ui-bootstrap-0.2.0.min.js',
//our app!
'app/assets/javascripts/<our-mini-app>/**',
// and our tests
'spec/javascripts/<our-mini-app>/lib/angular/angular-mocks.js',
'spec/javascripts/<our-mini-app>/unit/*.coffee',
// mocked data
'spec/javascripts/<our-mini-app>/mocked-data/<data-file>.js.coffee',
];
autoWatch = true;
browsers = 'PhantomJS'.split(' ')
preprocessors = {
'**/*.coffee': 'coffee'
}
fonte
2013-06-04 00:40:55
Ho creato una cartella/spec/angolare dove inserisco tutti i file di test, con/spec/angular/e2e,/spec/angular/unit, ecc ... Ma come hai configurato il karma.conf.js? Non sono sicuro se l'attributo proxy sia corretto: 'proxies = { '/': 'http: // localhost: 3000 /' };' Sto avendo errori per eseguire anche un semplice test, è come javascript le fonti da testare non sono incluse. – p1nox
PD: Sto lavorando con il codice legacy che usa application.js.erb come manifest per tutti i file javascript, anche angolari, nel mio karma.conf.js ho 'files = [ ANGULAR_SCENARIO, ANGULAR_SCENARIO_ADAPTER, '. ./../app/assets/javascripts/application.js ', ' */* Spec.js ' ]; ' – p1nox
BTW Sto testando se un modulo chiamato" StSelector "è lì e funziona (http: //www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-testacular.html#testing-modules), e sto ricevendo 'Midway: Moduli di test Modulo StSelector: dovrebbe essere registrato FAILED \t Errore: nessun modulo: StSelector' – p1nox