Skip to content

test(tracing): Check if beforeNavigate does not change source #7473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Changes from all commits
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
8 changes: 5 additions & 3 deletions packages/tracing-internal/test/browser/browsertracing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,20 @@ describe('BrowserTracing', () => {
expect(mockBeforeNavigation).toHaveBeenCalledTimes(1);
});

it('sets transaction name source to default `custom` if name is not changed', () => {
it('sets transaction name source to default `url` if name is not changed', () => {
const mockBeforeNavigation = jest.fn(ctx => ({
...ctx,
}));
createBrowserTracing(true, {
beforeNavigate: mockBeforeNavigation,
routingInstrumentation: customInstrumentRouting,
routingInstrumentation: (customStartTransaction: (obj: any) => void) => {
customStartTransaction({ name: 'a/path', op: 'pageload', metadata: { source: 'url' } });
},
});
const transaction = getActiveTransaction(hub) as IdleTransaction;
expect(transaction).toBeDefined();
expect(transaction.name).toBe('a/path');
expect(transaction.metadata.source).toBe('custom');
expect(transaction.metadata.source).toBe('url');

expect(mockBeforeNavigation).toHaveBeenCalledTimes(1);
});
Expand Down