File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5050 "prepublishOnly" : " npm ls" ,
5151 "install" : " node-pre-gyp install --fallback-to-build" ,
5252 "pretest" : " node test/support/createdb.js" ,
53- "test" : " mocha -R spec --timeout 480000"
53+ "test" : " mocha -R spec --timeout 480000" ,
54+ "test:worker" : " node --experimental-worker scripts/mocha-as-worker.js -R spec --timeout 480000"
5455 },
5556 "license" : " BSD-3-Clause" ,
5657 "keywords" : [
Original file line number Diff line number Diff line change 1+ // Run the mocha tests in a worker
2+ // Not a clean approach, but is sufficient to verify correctness
3+ const worker_threads = require ( "worker_threads" ) ;
4+ const path = require ( "path" ) ;
5+
6+ if ( worker_threads . isMainThread ) {
7+ const worker = new worker_threads . Worker ( __filename , { workerData : { windowSize : process . stdout . getWindowSize ( ) } } ) ;
8+ worker . on ( "error" , console . error ) ;
9+ } else {
10+ process . stdout . getWindowSize = ( ) => worker_threads . workerData . windowSize ;
11+ const mochaPath = path . resolve ( require . resolve ( "mocha" ) , "../bin/_mocha" ) ;
12+ require ( mochaPath ) ;
13+ }
You can’t perform that action at this time.
0 commit comments