Skip to content

Instantly share code, notes, and snippets.

@acthp
Created August 31, 2012 19:14
Show Gist options
  • Save acthp/3557646 to your computer and use it in GitHub Desktop.
Save acthp/3557646 to your computer and use it in GitHub Desktop.
requirejs (AMD) loader plugin for jstestdriver
(function() {
var loadSource = function(file, onSourceLoad) {
if (!file.fileSrc.match(/js-test/)) {
return false;
}
require([file.fileSrc], function() {
onSourceLoad({file: file, success: true, message: ''});
}, function(err) {
var msg = err.requireType;
if (err.requireModules) {
msg += ": " + err.requireModules.join(', ');
}
onSourceLoad({file: file, success: false, message: msg});
});
return true;
};
jstestdriver.pluginRegistrar.register({
name: 'AMDLoaderPlugin',
loadSource: loadSource
});
}());
@quannguyen81
Copy link

Hi acthp,

Do you have a working example that you could share? It seems like I am missing some key configurations here and there. It would be very helpful if you could help.

Thanks a lot in advance!

@mattnworb
Copy link

The easiest workaround I've found for this is to just put explicit module names inside each of my define() calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment