Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix new test
  • Loading branch information
Lms24 committed Dec 16, 2024
commit 88a6d95e798679b51866e4c0301e7565f765fd18
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sentryTest } from '../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../utils/helpers';

sentryTest(
'it captures console messages correctly and adds a synthetic stack trace if `attachStackTrace` is set to `true`',
'captures console messages correctly and adds a synthetic stack trace if `attachStackTrace` is set to `true`',
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

Expand Down Expand Up @@ -37,52 +37,104 @@ sentryTest(
);
expect(logEvent?.exception?.values![0]).toMatchObject({
mechanism: {
handled: false,
handled: true,
type: 'console',
synthetic: 'true',
synthetic: true,
},
value: 'console log',
stacktrace: {
frames: expect.any(Array),
},
});

expect(warnEvent).toEqual(
expect.objectContaining({
level: 'warning',
logger: 'console',
extra: {
arguments: ['console warn'],
},
message: 'console warn',
}),
);
expect(warnEvent?.exception).toBeUndefined();
expect(warnEvent?.exception?.values![0]).toMatchObject({
mechanism: {
handled: true,
type: 'console',
synthetic: true,
},
value: 'console warn',
stacktrace: {
frames: expect.any(Array),
},
});

expect(infoEvent).toEqual(
expect.objectContaining({
level: 'info',
logger: 'console',
extra: {
arguments: ['console info'],
},
message: 'console info',
}),
);
expect(infoEvent?.exception).toBeUndefined();
expect(infoEvent?.exception?.values![0]).toMatchObject({
mechanism: {
handled: true,
type: 'console',
synthetic: true,
},
value: 'console info',
stacktrace: {
frames: expect.any(Array),
},
});

expect(errorEvent).toEqual(
expect.objectContaining({
level: 'error',
logger: 'console',
extra: {
arguments: ['console error'],
},
message: 'console error',
}),
);
expect(errorEvent?.exception).toBeUndefined();
expect(errorEvent?.exception?.values![0]).toMatchObject({
mechanism: {
handled: true,
type: 'console',
synthetic: true,
},
value: 'console error',
stacktrace: {
frames: expect.any(Array),
},
});

expect(traceEvent).toEqual(
expect.objectContaining({
level: 'log',
logger: 'console',
extra: {
arguments: ['console trace'],
},
message: 'console trace',
}),
);
expect(traceEvent?.exception).toBeUndefined();
expect(traceEvent?.exception?.values![0]).toMatchObject({
mechanism: {
handled: true,
type: 'console',
synthetic: true,
},
value: 'console trace',
stacktrace: {
frames: expect.any(Array),
},
});

expect(errorWithErrorEvent).toEqual(
expect.objectContaining({
level: 'error',
Expand Down
Loading