Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Jul 28, 2022
1 parent 8120664 commit 01eb648
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ app.get('/test/express', (_req, res) => {
res.send({ response: 'response 1' });
});

app.get(/\/test\/regex/, (_req, res) => {
res.send({ response: 'response 2' });
});

app.use(Sentry.Handlers.errorHandler());

export default app;
26 changes: 26 additions & 0 deletions packages/node-integration-tests/suites/express/tracing/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,29 @@ test('should create and send transactions for Express routes and spans for middl
],
});
});

test('should set a correct transaction name for routes specified in RegEx', async () => {
const url = await runServer(__dirname, `${__dirname}/server.ts`);
const envelope = await getEnvelopeRequest(`${url}/regex`);

expect(envelope).toHaveLength(3);

assertSentryTransaction(envelope[2], {
transaction: 'GET /\\/test\\/regex/',
transaction_info: {
source: 'route',
},
contexts: {
trace: {
data: {
url: '/test/regex',
},
op: 'http.server',
status: 'ok',
tags: {
'http.status_code': '200',
},
},
},
});
});

0 comments on commit 01eb648

Please sign in to comment.