"main": "index.js",
"scripts": {
"build": "npm install",
- "test": "standard && nyc mocha --exit --timeout 10000 **/*test.js ",
+ "test": "standard && nyc mocha --experimental-worker --exit --timeout 10000 **/*test.js ",
"demontest": "nodemon --exec \"npm test\"",
"coverage": "nyc report --reporter=text-lcov --timeout 5000 **/*test.js | coveralls",
"standard-verbose": "npx standard --verbose",
it('Verify that new workers are created when required, max size is not exceeded and that after a while new workers will die', async () => {
const promises = []
let closedThreads = 0
+ let fullPool = 0
+ pool.emitter.on('FullPool', () => fullPool++)
for (let i = 0; i < (max * 3); i++) {
promises.push(pool.execute({ test: 'test' }))
}
closedThreads++
})
})
+ expect(fullPool > 1).toBeTruthy()
await new Promise(resolve => setTimeout(resolve, 1000 * 2))
expect(closedThreads).toBe(max - min)
})