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