Skip to content

Commit

Permalink
Reorganized config scripts, fleshed out comments and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerdinacan committed Nov 3, 2018
1 parent c2f71c3 commit 19b2fdd
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 143 deletions.
File renamed without changes.
81 changes: 0 additions & 81 deletions client/karma.config.qunit.js

This file was deleted.

18 changes: 12 additions & 6 deletions client/karma.config.base.js → client/karma/karma.config.base.js
@@ -1,15 +1,21 @@
var webpackConfig = require("./webpack.config.unittest");
/**
* Base karma config, assumes chrome headless and webpack
*/

const webpackConfig = require("./webpack.config.unittest");

module.exports = {
basepath: ".",
failOnEmptyTestSuite: false,
webpack: webpackConfig,
webpackMiddleware: { noInfo: true },
basePath: "../galaxy/scripts",
browsers: ["ChromeHeadlessNoSandbox"],
singleRun: true,
client: {
captureConsole: true
},
failOnEmptyTestSuite: false,
singleRun: true,
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: "ChromeHeadless",
Expand Down
@@ -1,20 +1,19 @@
/**
* Runs mocha tests
*/

const baseKarmaConfig = require("./karma.config.base");

// Single pack mode runs whole test suite much more quickly - but requires
// running the whole test suite so it would be slower for one-off tests.
const single_pack = (process.env.GALAXY_TEST_AS_SINGLE_PACK || false);
const single_pack = (process.env.GALAXY_TEST_AS_SINGLE_PACK == "true");

const testBundles = [
"galaxy/**/unitTestBundle.js",
"galaxy/**/mocha/test.js"
"**/unitTestBundle.js",
"**/mocha/test.js"
];

const separateTests = [
"galaxy/scripts/**/*.test.js",
"galaxy/**/mocha/tests/*_tests.js"
"**/*.test.js",
"**/mocha/tests/*_tests.js"
];

module.exports = function (config) {
Expand All @@ -33,10 +32,10 @@ module.exports = function (config) {

let settings = Object.assign({}, baseKarmaConfig, {
files: files,
exclude: ["galaxy/**/qunit/*"],
exclude: ["**/qunit/*"],
preprocessors: preprocessors,
reporters: ["mocha"],
frameworks: ["mocha", "chai"]
frameworks: ["polyfill", "mocha", "chai"]
});

config.set(settings);
Expand Down
80 changes: 80 additions & 0 deletions client/karma/karma.config.qunit.js
@@ -0,0 +1,80 @@
/**
* Qunit Tests
*
* These legacy QUnit tests are interdependent and only execute as a single
* package. A flaw in the previous node environment parameter-checking in the
* old karma configs gave the illusion that they ran individually, but they do
* not and probably never have. Keeping them around for now, but we should get
* rid of them by rewriting the tests or preferrably by removing the code to
* which they apply.
*
* TODO: Fix jquery bundle to deliver same plugins to all frames
* qunit/tests/page_tests
* This test does not work with ChromeHeadless, but does with PhantomJS The
* error is related to the jQuery bundling issue. Currently it can't find the
* select2 plugin because the frame pages are loading a different jquery load-out
* than the main UI.
*/

const baseKarmaConfig = require("./karma.config.base");

// Webpack config requires massaging because the QUnit tests require CSS because
// they are not truly unit tests. Normally webpack css and assets would be
// stripped out of a test bundle. Apparently these tests were written prior to
// selenium being implemented.
const webpackConfig = require("./webpack.config.qunit");

const testFiles = [
"qunit/test.js"
];

const assets = [
"qunit/assets/*.css"
];

module.exports = function (config) {

let preprocessors = testFiles.reduce((result, path) => {
result[path] = ["webpack"];
return result;
}, {});

let settings = Object.assign({}, baseKarmaConfig, {
files: testFiles.concat(assets),
preprocessors: preprocessors,
frameworks: ["polyfill", "qunit"],
webpack: webpackConfig
});

config.set(settings);
};


/*
var QUNIT_TESTS_SEPARATE_PACKS = [
{ pattern: "galaxy/scripts/qunit/tests/galaxy_app_base_tests.js", watched: false },
// Something is funky with form_tests.js - needs to come before all other tests.
{ pattern: "galaxy/scripts/qunit/tests/form_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/upload_dialog_tests.js", watched: false },
// Something is funky with masthead_tests - needs to come before one of the other
// tests - not sure which though...
{ pattern: "galaxy/scripts/qunit/tests/masthead_tests.js", watched: false },
//{pattern: 'galaxy/scripts/qunit/tests/list_of_pairs_collection_creator_tests.js', watched: false},
{ pattern: "galaxy/scripts/qunit/tests/graph_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/hda_base_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/history_contents_model_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/job_dag_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/metrics_logger_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/popover_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/utils_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/page_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/workflow_editor_tests.js", watched: false },
{ pattern: "galaxy/scripts/qunit/tests/modal_tests.js", watched: false }
// The following tests don't work for state reasons:
// Error: Following test works on its own or with rest but not with
// list_of_pairs_collection_creator in the same suite. Not as much isolation
// as seperate page setup of previous runner.
// {pattern: 'galaxy/scripts/qunit/tests/ui_tests.js', watched: false},
];
*/
44 changes: 44 additions & 0 deletions client/karma/webpack.config.qunit.js
@@ -0,0 +1,44 @@
/**
* So the legacy QUnit tests have to perform some gymastics that should not be
* required because thse tests apparently care about assets like the CSS and images.
* TODO: Replace these tests with like... actual unit tests.
*/

let wpConfig = require("../webpack.config");
wpConfig.mode = "production";
wpConfig.entry = () => ({});

const switchPlugin = (reMatcher, replacement) => {

let scrubLoader = (obj) =>
(typeof obj == "string" && obj.match(reMatcher))
? Object.assign({}, replacement)
: obj

return (rule) => {
if (rule.use && rule.use.length) {
rule.use = rule.use.map(scrubLoader);
}
return rule;
}
}

// Remove MiniCssExtractPlugin loader references
// replace mini-css-extract plugin with basic style loader
// Honestly I'm not clear on why we process css at all for unit tests
const scrubLoaderRules = (module) => {
let rePluginMatch = /mini-css-extract-plugin/;
let styleLoader = { loader: "style-loader" };
let processor = switchPlugin(rePluginMatch, styleLoader);
module.rules = module.rules.map(processor);
}

// Remove mini-css-extract loader references
scrubLoaderRules(wpConfig.module);

// remove MiniCSSExtract Plugin
wpConfig.plugins = wpConfig.plugins.filter(p => {
return p.constructor.name != "MiniCssExtractPlugin";
});

module.exports = wpConfig;
Expand Up @@ -4,12 +4,9 @@
*/

let merge = require("webpack-merge");
let wpConfig = require("./webpack.config");
let wpConfig = require("../webpack.config");

// set mode?
wpConfig.mode = "development";

// Don't build Galaxy bundles - build per-test bundles.
wpConfig.mode = "production";
wpConfig.entry = () => ({});

// Don't need assets for unit testing, override those rules
Expand Down
6 changes: 3 additions & 3 deletions client/package.json
Expand Up @@ -58,8 +58,8 @@
"webpack-production-maps": "GXY_BUILD_SOURCEMAPS=1 webpack -p",
"test": "npm run test-mocha && npm run test-qunit",
"test-watch": "npm run test-mocha -- --no-single-run",
"test-qunit": "GALAXY_TEST_AS_SINGLE_PACK=true karma start karma.config.qunit.js",
"test-mocha": "GALAXY_TEST_AS_SINGLE_PACK=true karma start karma.config.mocha.js",
"test-qunit": "GALAXY_TEST_AS_SINGLE_PACK=true karma start karma/karma.config.qunit.js",
"test-mocha": "GALAXY_TEST_AS_SINGLE_PACK=true karma start karma/karma.config.mocha.js",
"gulp": "gulp",
"gulp-production": "NODE_ENV=production gulp",
"gulp-production-maps": "GXY_BUILD_SOURCEMAPS=1 NODE_ENV=production gulp",
Expand Down Expand Up @@ -115,4 +115,4 @@
"webpack-merge": "^4.1.4",
"yaml-loader": "^0.5.0"
}
}
}
39 changes: 0 additions & 39 deletions client/webpack.config.qunit.js

This file was deleted.

0 comments on commit 19b2fdd

Please sign in to comment.