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:
David Taylor
2017-07-26 14:07:46 +01:00
committed by Sam
parent 917d186303
commit febd7621ea
5 changed files with 60 additions and 19 deletions

View File

@ -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();