From: Jérôme Benoit Date: Sat, 31 Aug 2024 21:09:33 +0000 (+0200) Subject: test: cleanup error handling expectations X-Git-Tag: v4.2.10~10 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d960e542b476b90385e962c9be41422860310426;p=poolifier.git test: cleanup error handling expectations Signed-off-by: Jérôme Benoit --- diff --git a/tests/pools/cluster/fixed.test.mjs b/tests/pools/cluster/fixed.test.mjs index 975e6e16..094e506d 100644 --- a/tests/pools/cluster/fixed.test.mjs +++ b/tests/pools/cluster/fixed.test.mjs @@ -176,9 +176,7 @@ describe('Fixed cluster pool test suite', () => { } catch (e) { inError = e } - expect(inError).toBeDefined() - expect(typeof inError === 'string').toBe(true) - expect(inError).toBe('Error Message from ClusterWorker') + expect(inError).toStrictEqual('Error Message from ClusterWorker') expect(taskError).toStrictEqual({ data, message: 'Error Message from ClusterWorker', @@ -207,9 +205,7 @@ describe('Fixed cluster pool test suite', () => { } catch (e) { inError = e } - expect(inError).toBeDefined() - expect(typeof inError === 'string').toBe(true) - expect(inError).toBe('Error Message from ClusterWorker:async') + expect(inError).toStrictEqual('Error Message from ClusterWorker:async') expect(taskError).toStrictEqual({ data, message: 'Error Message from ClusterWorker:async', diff --git a/tests/pools/thread/fixed.test.mjs b/tests/pools/thread/fixed.test.mjs index 7473ab54..2ffc6c93 100644 --- a/tests/pools/thread/fixed.test.mjs +++ b/tests/pools/thread/fixed.test.mjs @@ -202,11 +202,8 @@ describe('Fixed thread pool test suite', () => { } catch (e) { inError = e } - expect(inError).toBeDefined() expect(inError).toBeInstanceOf(Error) - expect(inError.message).toBeDefined() - expect(typeof inError.message === 'string').toBe(true) - expect(inError.message).toBe('Error Message from ThreadWorker') + expect(inError.message).toStrictEqual('Error Message from ThreadWorker') expect(taskError).toStrictEqual({ data, message: new Error('Error Message from ThreadWorker'), @@ -235,11 +232,10 @@ describe('Fixed thread pool test suite', () => { } catch (e) { inError = e } - expect(inError).toBeDefined() expect(inError).toBeInstanceOf(Error) - expect(inError.message).toBeDefined() - expect(typeof inError.message === 'string').toBe(true) - expect(inError.message).toBe('Error Message from ThreadWorker:async') + expect(inError.message).toStrictEqual( + 'Error Message from ThreadWorker:async' + ) expect(taskError).toStrictEqual({ data, message: new Error('Error Message from ThreadWorker:async'), diff --git a/tests/worker/cluster-worker.test.mjs b/tests/worker/cluster-worker.test.mjs index fcb6564e..732ba254 100644 --- a/tests/worker/cluster-worker.test.mjs +++ b/tests/worker/cluster-worker.test.mjs @@ -93,7 +93,6 @@ describe('Cluster worker test suite', () => { it('Verify that handleError() method is working properly', () => { const error = new Error('Error as an error') const worker = new ClusterWorker(() => {}) - expect(worker.handleError(error)).not.toBeInstanceOf(Error) expect(worker.handleError(error)).toStrictEqual(error.message) const errorMessage = 'Error as a string' expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage) diff --git a/tests/worker/thread-worker.test.mjs b/tests/worker/thread-worker.test.mjs index ed9f16ac..8f146b71 100644 --- a/tests/worker/thread-worker.test.mjs +++ b/tests/worker/thread-worker.test.mjs @@ -93,7 +93,6 @@ describe('Thread worker test suite', () => { it('Verify that handleError() method is working properly', () => { const error = new Error('Error as an error') const worker = new ThreadWorker(() => {}) - expect(worker.handleError(error)).toBeInstanceOf(Error) expect(worker.handleError(error)).toStrictEqual(error) const errorMessage = 'Error as a string' expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage)