From: aardizio Date: Sun, 19 Jan 2020 22:56:28 +0000 (+0100) Subject: Fix tests run on node 10.x and add test assertion X-Git-Tag: v0.0.1~30 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b755d5beab080feedc652bac13e376b902321040;p=poolifier.git Fix tests run on node 10.x and add test assertion --- diff --git a/package.json b/package.json index 4bbd2b8f..ca55edc6 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "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", diff --git a/tests/dynamic.test.js b/tests/dynamic.test.js index 7b0865bb..7c5eec12 100644 --- a/tests/dynamic.test.js +++ b/tests/dynamic.test.js @@ -16,6 +16,8 @@ describe('Dynamic thread pool test suite ', () => { 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' })) } @@ -25,6 +27,7 @@ describe('Dynamic thread pool test suite ', () => { closedThreads++ }) }) + expect(fullPool > 1).toBeTruthy() await new Promise(resolve => setTimeout(resolve, 1000 * 2)) expect(closedThreads).toBe(max - min) })