Factor out some UTs code in test-utils.js
[poolifier.git] / tests / worker-files / cluster / asyncErrorWorker.js
index b9fd9016ab91801122e4cb6394b5e590377b4f3f..0b6f5d8acb937a02bc4dcb47d855f6a89456ddc2 100644 (file)
@@ -1,13 +1,14 @@
 'use strict'
 const { ClusterWorker, KillBehaviors } = require('../../../lib/index')
+const TestUtils = require('../../test-utils')
 
 async function error (data) {
-  return new Promise((resolve, reject) => {
-    setTimeout(
-      () => reject(new Error('Error Message from ClusterWorker:async')),
-      2000
-    )
-  })
+  return TestUtils.workerSleepFunction(
+    data,
+    2000,
+    true,
+    'Error Message from ClusterWorker:async'
+  )
 }
 
 module.exports = new ClusterWorker(error, {