-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node): Improve non-error messages (#9026)
- Loading branch information
Showing
4 changed files
with
58 additions
and
9 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
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
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,32 @@ | ||
import type { Hub } from '@sentry/types'; | ||
|
||
import { createStackParser, eventFromUnknownInput, nodeStackLineParser } from '../src'; | ||
|
||
function getCurrentHub(): Hub { | ||
// Some fake hub to get us through | ||
return { getClient: () => undefined, configureScope: () => {} } as unknown as Hub; | ||
} | ||
|
||
const stackParser = createStackParser(nodeStackLineParser()); | ||
|
||
describe('eventFromUnknownInput', () => { | ||
test('object with useless props', () => { | ||
const event = eventFromUnknownInput(getCurrentHub, stackParser, { foo: { bar: 'baz' }, prop: 1 }); | ||
expect(event.exception?.values?.[0].value).toBe('Object captured as exception with keys: foo, prop'); | ||
}); | ||
|
||
test('object with name prop', () => { | ||
const event = eventFromUnknownInput(getCurrentHub, stackParser, { foo: { bar: 'baz' }, name: 'BadType' }); | ||
expect(event.exception?.values?.[0].value).toBe("'BadType' captured as exception"); | ||
}); | ||
|
||
test('object with name and message props', () => { | ||
const event = eventFromUnknownInput(getCurrentHub, stackParser, { message: 'went wrong', name: 'BadType' }); | ||
expect(event.exception?.values?.[0].value).toBe("'BadType' captured as exception with message 'went wrong'"); | ||
}); | ||
|
||
test('object with message prop', () => { | ||
const event = eventFromUnknownInput(getCurrentHub, stackParser, { foo: { bar: 'baz' }, message: 'Some message' }); | ||
expect(event.exception?.values?.[0].value).toBe('Some message'); | ||
}); | ||
}); |