Skip to content

Commit 5a12eed

Browse files
authored
test: Use %j instead of %p placeholder for vitest (#16258)
See https://vitest.dev/api/#test-each, `%p` does not exist there.
1 parent 558d3ff commit 5a12eed

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

packages/browser/test/tracing/request.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('shouldAttachHeaders', () => {
183183
['https://my-origin.com?my-query', 'my-query', true],
184184
['https://not-my-origin.com?my-query', 'my-query', true],
185185
])(
186-
'for url %p and tracePropagationTarget %p on page "https://my-origin.com/api/my-route" should return %p',
186+
'for url %j and tracePropagationTarget %j on page "https://my-origin.com/api/my-route" should return %j',
187187
(url, matcher, result) => {
188188
expect(shouldAttachHeaders(url, [matcher])).toBe(result);
189189
},
@@ -234,7 +234,7 @@ describe('shouldAttachHeaders', () => {
234234
'https://not-my-origin.com/api',
235235
'https://my-origin.com?my-query',
236236
'https://not-my-origin.com?my-query',
237-
])('should return false for everything if tracePropagationTargets are empty (%p)', url => {
237+
])('should return false for everything if tracePropagationTargets are empty (%j)', url => {
238238
expect(shouldAttachHeaders(url, [])).toBe(false);
239239
});
240240

@@ -266,7 +266,7 @@ describe('shouldAttachHeaders', () => {
266266
['http://localhost:3000', false],
267267
['https://somewhere.com/test/localhost/123', false],
268268
['https://somewhere.com/test?url=https://my-origin.com', false],
269-
])('for URL %p should return %p', (url, expectedResult) => {
269+
])('for URL %j should return %j', (url, expectedResult) => {
270270
expect(shouldAttachHeaders(url, undefined)).toBe(expectedResult);
271271
});
272272
});
@@ -327,7 +327,7 @@ describe('shouldAttachHeaders', () => {
327327
['https://not-my-origin.com/api', 'api', true],
328328
['https://my-origin.com?my-query', 'my-query', true],
329329
['https://not-my-origin.com?my-query', 'my-query', true],
330-
])('for url %p and tracePropagationTarget %p should return %p', (url, matcher, result) => {
330+
])('for url %j and tracePropagationTarget %j should return %j', (url, matcher, result) => {
331331
expect(shouldAttachHeaders(url, [matcher])).toBe(result);
332332
});
333333
});

packages/core/test/lib/utils/merge.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('merge', () => {
6969
a0a: 'a0a',
7070
},
7171
],
72-
])('works with %p and %p', (oldData, newData, expected) => {
72+
])('works with %j and %j', (oldData, newData, expected) => {
7373
const actual = merge(oldData, newData as any);
7474
expect(actual).toEqual(expected);
7575
});

packages/core/test/lib/utils/parseSampleRate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('parseSampleRate', () => {
1717
['1.5', undefined],
1818
['0.555', 0.555],
1919
['0', 0],
20-
])('works with %p', (input, sampleRate) => {
20+
])('works with %j', (input, sampleRate) => {
2121
const actual = parseSampleRate(input);
2222
expect(actual).toBe(sampleRate);
2323
});

packages/node/test/integrations/http.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('httpIntegration', () => {
1111
[{ spans: false }, { skipOpenTelemetrySetup: true }, false],
1212
[{}, { skipOpenTelemetrySetup: true }, false],
1313
[{}, { skipOpenTelemetrySetup: false }, true],
14-
])('returns the correct value for options=%p and clientOptions=%p', (options, clientOptions, expected) => {
14+
])('returns the correct value for options=%j and clientOptions=%j', (options, clientOptions, expected) => {
1515
const actual = _shouldInstrumentSpans(options, clientOptions);
1616
expect(actual).toBe(expected);
1717
});

packages/opentelemetry/test/utils/spanTypes.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('spanTypes', () => {
88
[{}, false],
99
[{ attributes: null }, false],
1010
[{ attributes: {} }, true],
11-
])('works with %p', (span, expected) => {
11+
])('works with %j', (span, expected) => {
1212
const castSpan = span as unknown as Span;
1313
const actual = spanHasAttributes(castSpan);
1414

@@ -27,7 +27,7 @@ describe('spanTypes', () => {
2727
[{ kind: 0 }, true],
2828
[{ kind: 5 }, true],
2929
[{ kind: 'TEST_KIND' }, false],
30-
])('works with %p', (span, expected) => {
30+
])('works with %j', (span, expected) => {
3131
const castSpan = span as unknown as Span;
3232
const actual = spanHasKind(castSpan);
3333

@@ -44,7 +44,7 @@ describe('spanTypes', () => {
4444
[{}, false],
4545
[{ parentSpanId: null }, false],
4646
[{ parentSpanId: 'TEST_PARENT_ID' }, true],
47-
])('works with %p', (span, expected) => {
47+
])('works with %j', (span, expected) => {
4848
const castSpan = span as unknown as Span;
4949
const actual = spanHasParentId(castSpan);
5050

@@ -61,7 +61,7 @@ describe('spanTypes', () => {
6161
[{}, false],
6262
[{ events: null }, false],
6363
[{ events: [] }, true],
64-
])('works with %p', (span, expected) => {
64+
])('works with %j', (span, expected) => {
6565
const castSpan = span as unknown as Span;
6666
const actual = spanHasEvents(castSpan);
6767

packages/replay-internal/test/unit/coreHandlers/handleBreadcrumbs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { normalizeBreadcrumb, normalizeConsoleBreadcrumb } from '../../../src/co
55
describe('Unit | coreHandlers | handleBreadcrumbs', () => {
66
describe('normalizeBreadcrumb', () => {
77
it.each([undefined, 'ui.click', 'ui.scroll', 'fetch', 'xhr', 'sentry.event', 'sentry.transaction'])(
8-
'returns null if breadcrumb has category=%p',
8+
'returns null if breadcrumb has category=%j',
99
category => {
1010
const actual = normalizeBreadcrumb({ category });
1111
expect(actual).toBeNull();

packages/replay-internal/test/unit/coreHandlers/handleClick.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ describe('Unit | coreHandlers | handleClick', () => {
509509
['a', { target: '_blank' }, true],
510510
['a', { download: '' }, true],
511511
['a', { href: 'xx' }, false],
512-
])('it works with <%s> & %p', (tagName, attributes, expected) => {
512+
])('it works with <%s> & %j', (tagName, attributes, expected) => {
513513
const node = document.createElement(tagName);
514514
Object.entries(attributes).forEach(([key, value]) => {
515515
node.setAttribute(key, value);

packages/replay-internal/test/unit/util/isSampled.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Unit | util | isSampled', () => {
1818
const mockRandom = vi.spyOn(Math, 'random');
1919

2020
test.each(cases)(
21-
'given sample rate of %p and RNG returns %p, result should be %p',
21+
'given sample rate of %j and RNG returns %j, result should be %j',
2222
(sampleRate: number, mockRandomValue: number, expectedResult: boolean) => {
2323
mockRandom.mockImplementationOnce(() => mockRandomValue);
2424
const result = isSampled(sampleRate);

packages/vue/test/router.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ describe('instrumentVueRouter()', () => {
328328
[false, 0],
329329
[true, 1],
330330
])(
331-
'should return instrumentation that considers the instrumentPageLoad = %p',
331+
'should return instrumentation that considers the instrumentPageLoad = %j',
332332
(instrumentPageLoad, expectedCallsAmount) => {
333333
const mockRootSpan = {
334334
...MOCK_SPAN,
@@ -368,7 +368,7 @@ describe('instrumentVueRouter()', () => {
368368
[false, 0],
369369
[true, 1],
370370
])(
371-
'should return instrumentation that considers the instrumentNavigation = %p',
371+
'should return instrumentation that considers the instrumentNavigation = %j',
372372
(instrumentNavigation, expectedCallsAmount) => {
373373
const mockStartSpan = vi.fn().mockReturnValue(MOCK_SPAN);
374374
instrumentVueRouter(

0 commit comments

Comments
 (0)