Skip to content

Commit d5ba31e

Browse files
committed
review suggestions
1 parent c9bd340 commit d5ba31e

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

packages/vue/test/tracing/tracingMixin.test.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('Vue Tracing Mixins', () => {
114114
});
115115

116116
describe('Root Component Behavior', () => {
117-
it('should always create root span for root component regardless of tracking options', () => {
117+
it('should always create a span for the Vue root component regardless of tracking options', () => {
118118
const mixins = createTracingMixins({ trackComponents: false });
119119

120120
mixins.beforeMount.call(mockRootInstance);
@@ -208,28 +208,30 @@ describe('Vue Tracing Mixins', () => {
208208
});
209209

210210
describe('Component Tracking Options', () => {
211-
it('should respect tracking configuration options', () => {
212-
// Test different tracking configurations with the same component
213-
const runTracingTest = (trackComponents: boolean | string[] | undefined, shouldTrack: boolean) => {
214-
vi.clearAllMocks();
215-
const mixins = createTracingMixins({ trackComponents });
216-
mixins.beforeMount.call(mockVueInstance);
217-
218-
if (shouldTrack) {
219-
expect(startInactiveSpan).toHaveBeenCalled();
220-
} else {
221-
expect(startInactiveSpan).not.toHaveBeenCalled();
222-
}
223-
};
211+
it.each([
212+
{ trackComponents: undefined, expected: false, description: 'defaults to not tracking components' },
213+
{ trackComponents: false, expected: false, description: 'does not track when explicitly disabled' },
214+
])('$description', ({ trackComponents }) => {
215+
const mixins = createTracingMixins({ trackComponents });
216+
mixins.beforeMount.call(mockVueInstance);
217+
expect(startInactiveSpan).not.toHaveBeenCalled();
218+
});
224219

225-
// Test all tracking configurations
226-
runTracingTest(undefined, false); // Default - don't track
227-
runTracingTest(false, false); // Explicitly disabled
228-
runTracingTest(true, true); // Track all components
229-
runTracingTest(['TestComponent'], true); // Track by name (match)
220+
it.each([
221+
{ trackComponents: true, description: 'tracks all components when enabled' },
222+
{ trackComponents: ['TestComponent'], description: 'tracks components that match the name list' },
223+
])('$description', ({ trackComponents }) => {
224+
const mixins = createTracingMixins({ trackComponents });
225+
mixins.beforeMount.call(mockVueInstance);
226+
expect(startInactiveSpan).toHaveBeenCalledWith(
227+
expect.objectContaining({
228+
name: 'Vue TestComponent',
229+
op: 'ui.vue.mount',
230+
}),
231+
);
232+
});
230233

231-
// Test component not in tracking list
232-
vi.clearAllMocks();
234+
it('does not track components not in the tracking list', () => {
233235
const mixins = createTracingMixins({ trackComponents: ['OtherComponent'] });
234236
mixins.beforeMount.call(mockVueInstance); // TestComponent
235237
expect(startInactiveSpan).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)