mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
Qunit plugin rake tasks (#4985)
* Allow running specific plugin tests using ENV variables * Add a `rake plugin:qunit` task to match the existing `rake plugin:spec` task * Improve docker.rake to allow running specific plugin qunit tests * Purge cache before and after qunit tests * Stop module auto-loader trying to auto-load tests * Use URL query parameters to pass config into Qunit, avoiding caching issues * Oops, searchParams doesn’t work in phantomJS. Parse the URL manually. * Escape ampersands before passing URL to phantomJS, otherwise multiple parameters go wrong
This commit is contained in:
@ -138,10 +138,25 @@ window.asyncTestDiscourse = helpers.asyncTestDiscourse;
|
||||
window.controllerFor = helpers.controllerFor;
|
||||
window.fixture = helpers.fixture;
|
||||
|
||||
function getUrlParameter(name) {
|
||||
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
||||
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
||||
var results = regex.exec(location.search);
|
||||
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
var skipCore = (getUrlParameter('qunit_skip_core') == '1');
|
||||
var pluginPath = getUrlParameter('qunit_single_plugin') ? "\/"+getUrlParameter('qunit_single_plugin')+"\/" : "\/plugins\/";
|
||||
|
||||
Object.keys(requirejs.entries).forEach(function(entry) {
|
||||
if ((/\-test/).test(entry)) {
|
||||
var isTest = (/\-test/).test(entry);
|
||||
var regex = new RegExp(pluginPath)
|
||||
var isPlugin = regex.test(entry);
|
||||
|
||||
if (isTest && (!skipCore || isPlugin)) {
|
||||
require(entry, null, null, true);
|
||||
}
|
||||
});
|
||||
|
||||
resetSite();
|
||||
|
||||
|
Reference in New Issue
Block a user