test not running on karma/jasmine/require.js 'There is no timestamp for *lib*!' error

空扰寡人 提交于 2019-12-22 06:47:15

问题


I change the code, extend some functionality and add new unittest for that. Now, when I run my unit tests with karma (test framework - jasmine), it throw me an error

'There is no timestamp for /libs/angular-bootstrap/ui-bootstrap-tpls.js!'
Uncaught Error: Script error for: angular-bootstrap
http://requirejs.org/docs/errors.html#scripterror
at http://localhost:9876/base/node_modules/karma-requirejs/lib/require.js?1379984163000:138

What I'm doing wrong?


回答1:


It was my mistake completely. when using karma-requirejs you have main-test.js file where configure how to require.js get the files. I add reference to angular-bootstrap with mistake, that's why require.js couldn't find this file and throwing this mistake. So in my case this error means wrong file name provided.




回答2:


It can be because it cannot access your source file. You should configure karma to serve scripts where require will look for them. For example have the config in the karma conf

files:[{pattern: 'node_modules/**/*.js', included:false}]



回答3:


The question is old, the OP already solved his problem by now, but I'll add my two cents:

From the error message (end of the first error line) we can conclude that you were including a paths (or deps) file in main-test.js with the .js extension. In RequireJS, you need to call the file names without the extension, so your paths (or deps) would look more or less like this:

paths: {
    'ui-bootstrap': 'libs/angular-bootstrap/ui-bootstrap-tpls' // <- without the extension
}


来源:https://stackoverflow.com/questions/19016478/test-not-running-on-karma-jasmine-require-js-there-is-no-timestamp-for-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!