-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename to ErrorReporter and improve code
- Loading branch information
Showing
4 changed files
with
69 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/@n8n/task-runner/src/__tests__/error-reporter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { mock } from 'jest-mock-extended'; | ||
import { ApplicationError } from 'n8n-workflow'; | ||
|
||
import { ErrorReporter } from '../error-reporter'; | ||
|
||
describe('ErrorReporter', () => { | ||
const errorReporting = new ErrorReporter(mock()); | ||
|
||
describe('beforeSend', () => { | ||
it('should return null if originalException is an ApplicationError with level warning', () => { | ||
const hint = { originalException: new ApplicationError('Test error', { level: 'warning' }) }; | ||
expect(errorReporting.beforeSend(mock(), hint)).toBeNull(); | ||
}); | ||
|
||
it('should return event if originalException is an ApplicationError with level error', () => { | ||
const hint = { originalException: new ApplicationError('Test error', { level: 'error' }) }; | ||
expect(errorReporting.beforeSend(mock(), hint)).not.toBeNull(); | ||
}); | ||
|
||
it('should return null if originalException is an Error with a non-unique stack', () => { | ||
const hint = { originalException: new Error('Test error') }; | ||
errorReporting.beforeSend(mock(), hint); | ||
expect(errorReporting.beforeSend(mock(), hint)).toBeNull(); | ||
}); | ||
|
||
it('should return event if originalException is an Error with a unique stack', () => { | ||
const hint = { originalException: new Error('Test error') }; | ||
expect(errorReporting.beforeSend(mock(), hint)).not.toBeNull(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters