-
-
Save acthp/3557646 to your computer and use it in GitHub Desktop.
(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 | |
}); | |
}()); |
Great work! Finally a solution for testing AMD modules with dependancies! One comment, shouldn´t this plugin be loaded after require.js (in the jstd config file)? I had to move it after to get it working.
acthp, I am trying to get this working and am running into problems where it doesn't seem as though the plugin gets loaded. What do you mean by, the first time jstd loads source, it doesn't use the loadSource plugin? Does the reset flag need to be on the server and client instance of jstd?
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!
The easiest workaround I've found for this is to just put explicit module names inside each of my define()
calls.
Important safety tip: the first time jstd loads source, it does not use the loadSource plugin. I'm not sure how to coerce it to load and activate the plugin before loading other source. To activate it, always use the '--reset' flag when running tests.