karma-requirejs
karma-requirejs copied to clipboard
split out require-config for reuse in tests
Rather than copy-pasting the requirejs.config paths and shims into the require.config for running tests, we can just load the applications requirejs configuration from test-main.js
.
This PR was inspired by @jugglinMike's blog post on Effective Unit Testing with AMD.
Does that work with the paths defined in require-config? It seems to me that if require-config.js
defines a baseUrl
(js) with paths
and test-main.js
defines a different baseUrl
(base/js) the paths
defined in require-config.js
can't be used in the tests, as they will be served at base/js
but the paths
point to modules located at js
.
@uuilee Check out that article Craig referenced :)
@jugglinmike, thanks fot the reference. For some reason I can't get my tests to work using:
require.config({
baseUrl: '/base/js',
deps: ['/base/js/src/config.js'],
callback: function() {
'use strict';
require(tests, window.__karma__.start);
}
});
instead i had to do the following:
require(['/base/js/src/config.js'], function() {
'use strict';
require.config({
baseUrl: '/base/js',
callback: function() {
require(tests, window.__karma__.start);
}
});
});
In the former, it seemed that the baseUrl
did not get properly overriden to /base/js
.
This really should be merged, as it simplifies the setup.