-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathcreateErrorFieldFromRawError.spec.ts
More file actions
43 lines (40 loc) · 1.25 KB
/
createErrorFieldFromRawError.spec.ts
File metadata and controls
43 lines (40 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { ErrorHandling, ErrorSource, type RawError, type RelativeTime, type TimeStamp } from '@datadog/browser-core'
import { createErrorFieldFromRawError } from './createErrorFieldFromRawError'
describe('createErrorFieldFromRawError', () => {
const exhaustiveRawError: Required<RawError> = {
startClocks: {
relative: 0 as RelativeTime,
timeStamp: 0 as TimeStamp,
},
source: ErrorSource.LOGGER,
handling: ErrorHandling.HANDLED,
handlingStack: 'Error\n at foo (bar)',
componentStack: 'at Flex',
originalError: new Error('baz'),
type: 'qux',
message: 'quux',
stack: 'quuz',
file: 'https://example.com/quux.js',
causes: [],
fingerprint: 'corge',
csp: {
disposition: 'enforce',
},
context: {
foo: 'bar',
},
}
it('creates an error field from a raw error', () => {
expect(createErrorFieldFromRawError(exhaustiveRawError)).toEqual({
message: undefined,
kind: 'qux',
stack: 'quuz',
causes: [],
fingerprint: 'corge',
handling: ErrorHandling.HANDLED,
})
})
it('includes the message if includeMessage is true', () => {
expect(createErrorFieldFromRawError(exhaustiveRawError, { includeMessage: true }).message).toBe('quux')
})
})