sysgears / mochapack

Mocha test runner with integrated webpack precompiler
https://sysgears.github.io/mochapack/
MIT License
183 stars 28 forks source link

Support mocha-parallel-tests #3

Open stevefan1999-personal opened 5 years ago

stevefan1999-personal commented 5 years ago

If we are able to use https://github.com/mocha-parallel/mocha-parallel-tests, this could greatly benefit the test speed.

larixer commented 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

ztalbot2000 commented 4 years ago

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;

ztalbot2000 commented 4 years ago

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

ztalbot2000 commented 4 years ago

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)); }

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

leegee commented 4 years ago

Lack of this feature is why imma begrudgingly move to Jest..