} 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',
} 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',
} 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'),
} 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'),
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)
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)