Skip to content

Commit 3be2092

Browse files
authored
test(browser-integration): Fix incorrect tag value assertions (#18162)
Fixes faulty test assertions where we asserted for certain properties to _not_ be in an object but used `toMatchObject` to do so.
1 parent b6a7773 commit 3be2092

File tree

2 files changed

+11
-3
lines changed
  • dev-packages/browser-integration-tests/suites/public-api/setTag

2 files changed

+11
-3
lines changed

dev-packages/browser-integration-tests/suites/public-api/setTag/with_non_primitives/test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ import type { Event } from '@sentry/core';
33
import { sentryTest } from '../../../../utils/fixtures';
44
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
55

6-
sentryTest('should not accept non-primitive tags', async ({ getLocalTestUrl, page }) => {
6+
sentryTest('[bug] accepts non-primitive tags', async ({ getLocalTestUrl, page }) => {
7+
// this is a bug that went unnoticed due to type definitions and a bad assertion
8+
// TODO: We should not accept non-primitive tags. Fix this as a follow-up.
79
const url = await getLocalTestUrl({ testDir: __dirname });
810

911
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
1012

1113
expect(eventData.message).toBe('non_primitives');
12-
expect(eventData.tags).toMatchObject({});
14+
15+
// TODO: This should be an empty object but instead, it is:
16+
expect(eventData.tags).toEqual({
17+
tag_1: {},
18+
tag_2: [],
19+
tag_3: ['a', {}],
20+
});
1321
});

dev-packages/browser-integration-tests/suites/public-api/setTag/with_primitives/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sentryTest('should set primitive tags', async ({ getLocalTestUrl, page }) => {
99
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
1010

1111
expect(eventData.message).toBe('primitive_tags');
12-
expect(eventData.tags).toMatchObject({
12+
expect(eventData.tags).toEqual({
1313
tag_1: 'foo',
1414
tag_2: 3.141592653589793,
1515
tag_3: false,

0 commit comments

Comments
 (0)