javascript - Requirejs and Karma: cannot detect the source file -


i trying test angular scripts using karma , requirejs, keep getting error

firefox 28.0.0 (mac os x 10.9) error: 'there no timestamp /base/app/public/js/test/unit/controllersspec.js!'

warn [web-server]: 404: /base/app/public/js/test/unit/controllersspec.js

firefox 28.0.0 (mac os x 10.9) error error: script error for: test/unit/controllersspec http://requirejs.org/docs/errors.html#scripterror @ /users/masanori/desktop/flippysurvey/node_modules/requirejs/require.js:166

i tried changing baseurl in different ways still keep receiving error. can me figure out problem? i'll appreciate help!

my directory structure this

app/    public/        vendors/             ....        js/           controllers.js           controllers/                    mainctrl.js test    unit         controllersspec.js    karma.conf.js    test-main.js 

here test-main.js , karma.conf.js

test-main.js'  var alltestfiles = []; var test_regexp = /(spec|test)\.js$/i;  var pathtomodule = function(path) {   return path.replace(/^\/base\//, '').replace(/\.js$/, ''); };  object.keys(window.__karma__.files).foreach(function(file) {   if (test_regexp.test(file)) {     // normalize paths requirejs module names.     alltestfiles.push(pathtomodule(file));   } });  require.config({   paths:{     'angular'     : '/base/app/public/vendors/angular/angular',     'angularmocks': '/base/app/public/vendors/angular-mock/angular-mock',     'domready'    : '/base/app/public/vendors/requirejs-domready/domready',     'angularroute': '/base/app/public/vendors/angular-route/angular-route'   },    baseurl: '/base/app/public/js',    shim: {     'angular' :{'exports':'angular'},     'angularroute' :['angular'],     'angularmocks':{       deps: ['angular'],       'exports':'angular.mock'     }   },    deps: alltestfiles,    callback: window.__karma__.start }); 

karma.conf.js

module.exports = function(config) {      config.set({      basepath: '',      frameworks: ['jasmine', 'requirejs'],      files: [       {pattern: 'unit/*.js', included: false},       {pattern: 'unit/**/*.js', included: false},       {pattern: '../app/public/js/**/*.js', included: false},       {pattern: '../app/public/js/*.js', included: false},       {pattern: '../app/public/vendors/**/*.js', included: false},       'test-main.js'     ],      exclude: [      ],      preprocessors: {      },      reporters: ['progress'],      port: 9876,      colors: true,      // possible values: config.log_disable || config.log_error || config.log_warn || config.log_info || config.log_debug     loglevel: config.log_info,      autowatch: true,      browsers: ['firefox'],      singlerun: false   }); }; 

okay.

i had rid of code, karma automatically inserts when karma init requirejs.


in test-main.js

var pathtomodule = function(path) {   return path.replace(/^\/base\//, '').replace(/\.js$/, ''); }; object.keys(window.__karma__.files).foreach(function(file) {    if (test_regexp.test(file)) {    // normalize paths requirejs module names.     alltestfiles.push(pathtomodule(file));    } }); 

remove pathtomodule

object.keys(window.__karma__.files).foreach(function(file) {    if (test_regexp.test(file)) {       alltestfiles.push(file);     } }); 

now karma reads test files!


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -