Open stevefan1999-personal opened 5 years ago
This is doable, but it is certainly far from being easy, it is pretty hard. mocha-parallel-tests
approach won't work here, because it doesn't deal with potentially slow webpack compilation process. The best way to implement it, IMHO, is to have one master process that runs webpack and many worker processes that will receive from master process compiled tests, each time compilation happens. Worker process will then run the received compiled tests from in-memory filesystem. Node Cluster API should be used for implementation:
https://nodejs.org/api/cluster.html
Hmm, I tried the obvious but that did not work. Warning Passing multiple configs as an Array is not really supported. Only the first element will be parsed WEBPACK Compiling...
[=========================] 100% (completed)
WEBPACK Failed to compile with 4 error(s)
Error in ./app/XXXXX/XXX.ts
Module parse failed: Unexpected token (15:10) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | { | //O public var location:Number;
public location: number;
since I joined the config files I could not test it. my mistake, this quick fix does resolve my issue as a temp fix. ill send you my changes later
The reason why the patch works by only returning webpack.config.js, Configuration[0] is that webpack compiles the source, handling the multiple array; mochapack is passed the paths to the compiled code and or either array elements can compile the code, just the final bundle is different. so in this case, it works for me and the patch is backward compatible.
cat requireWebpackConfig.js.patch --- src/cli/requireWebpackConfig.js 2019-12-08 19:14:05.000000000 -0500 +++ src/cli/requireWebpackConfig.js.new 2019-12-08 19:12:45.000000000 -0500 @@ -106,12 +106,14 @@ config = await Promise.resolve(config(env)); }
if (mode != null) {
config.mode = mode;
if (Array.isArray(config)) {
console.log("\x1b[35m Warning \x1b[30m" + 'Passing multiple webpack.configs as an Array is not fully supported. Only the first element will be parsed');
config = config.shift(); }
if (Array.isArray(config)) {
throw new Error('Passing multiple configs as an Array is not supported. Please provide a single config instead.');
if (mode != null) {
config.mode = mode; }
return config;
This may all that be needed for some people like myself as like you said, creating multiple child tasks with a task manager is much more complex.
thanks, John Talbot
Lack of this feature is why imma begrudgingly move to Jest..
If we are able to use https://github.com/mocha-parallel/mocha-parallel-tests, this could greatly benefit the test speed.