build: ensure JS tests fail when the Karma Webpack build fails
Adds a "DieHardPlugin" to the Webpack build. See enclosed code comment for more details.
This commit is contained in:
committed by
Kyle McCormick
parent
9e470550ee
commit
50298f9dcb
@@ -26,6 +26,27 @@ var defineFooter = new RegExp('(' + defineCallFooter.source + ')|('
|
||||
var staticRootLms = process.env.STATIC_ROOT_LMS || './test_root/staticfiles';
|
||||
var staticRootCms = process.env.STATIC_ROOT_CMS || (staticRootLms + '/studio');
|
||||
|
||||
class DieHardPlugin {
|
||||
/* A small plugin which ensures that if Webpack fails, it causes the surrounding process to fail
|
||||
* as well. This helps us prevent JavaScript CI from "false passing" upon build failures--that is,
|
||||
* we want to avoid having another situation where the Webpack build breaks under Karma (our
|
||||
* test runner) but Karma just lets it slide and moves on to the next test suite.
|
||||
*
|
||||
* One would imagine that this would be Webpack's default behavior (and maybe it is?) but,
|
||||
* regardless, karma-webpack does not seem to consider Webpack build failures to be fatal errors
|
||||
* without this plugin. We don't fully understand it, but this is good enough given that we plan
|
||||
* to remove all JS in this repo soon (https://github.com/openedx/edx-platform/issues/31620).
|
||||
*
|
||||
* Inpsired by: https://github.com/codymikol/karma-webpack/issues/49#issuecomment-842682050
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.failed.tap('DieHardPlugin', (error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var workerConfig = function() {
|
||||
try {
|
||||
return {
|
||||
@@ -153,6 +174,7 @@ module.exports = Merge.smart({
|
||||
// any other way to declare that dependency.
|
||||
$script: 'scriptjs'
|
||||
}),
|
||||
new DieHardPlugin(),
|
||||
],
|
||||
|
||||
module: {
|
||||
|
||||
Reference in New Issue
Block a user