Require.js does not prepend baseUrl to dependencies
Hi,
I am trying to use Karma for my application's unit testing. I use Require.js in my app. Below is the directory structure -
|-app
|--all/app/code/goes here
|-public
|--external/lib/goes here
|-test
|--test-spec.js
|-test-main.js
|-karma.conf.js
The problem is that in my UT spec.js file when I include the dependency from app folder, the baseUrl (/base) does not get prefixed to the path resulting in 404.
WARN [web-server]: 404: /app/common/models/metadata.js
If I change the path in dependencies list to /base/app-client/common/models/metadata.js, it works fine. Similarly all the other dependencies of the models are resulting in 404 as well.
Here is my test-main.js config -
requirejs.config({
// Karma serves files from '/base'
baseUrl: '/base',
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: [
'underscore',
'jquery'
],
exports: 'Backbone'
},
runtime: {
exports: 'runtime'
},
Creatr: {
deps: [
'backbone'
],
exports: 'creatr'
}
},
paths: {
'jquery': 'public/lib/jquery/jquery.min',
'jquery.min.map': 'public/lib/jquery/jquery.min',
'underscore': 'public/lib/underscore/underscore',
'backbone': 'public/lib/backbone/backbone'
},
// ask Require.js to load these files (all our tests)
deps: [
'backbone',
'/base/test/test-spec.js'
],
// start test run, once Require.js is done
callback: window.__karma__.start
});
Please let me know what am I missing.
Thanks.
I met a similar error as this, but it's because I misspelled my dependencies with a ".js" which should be removed. Say, the dependency should be "a/b" rather "a/b.js". Not sure if this helps:)
Is this still an issue?