Skip to content

Commit 0e46720

Browse files
committed
test(node): add tests for fastify routerPath deprecation warning
1 parent 08ab96d commit 0e46720

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
2+
import * as Sentry from '@sentry/node';
3+
4+
Sentry.init({
5+
dsn: 'https://[email protected]/1337',
6+
release: '1.0',
7+
transport: loggingTransport,
8+
});
9+
10+
import { startFastifyServerAndSendPortToRunner } from '@sentry-internal/node-integration-tests';
11+
import Fastify from 'fastify';
12+
13+
const app = Fastify();
14+
15+
app.get('/test/deprecated', (_req, res) => {
16+
res.send({});
17+
});
18+
19+
Sentry.setupFastifyErrorHandler(app);
20+
21+
startFastifyServerAndSendPortToRunner(app);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { AxiosError } from 'axios';
2+
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';
3+
4+
afterAll(() => {
5+
cleanupChildProcesses();
6+
});
7+
8+
test('suppress fastify deprecation warning when `routerPath` property is accessed', async () => {
9+
// ensures that the assertions in the catch block are called
10+
expect.assertions(3);
11+
12+
const runner = createRunner(__dirname, 'server.ts').start();
13+
14+
try {
15+
// Axios from `makeRequest` will throw 404.
16+
await runner.makeRequest('get', '/test/deprecated/does-not-exist');
17+
} catch (error: any) {
18+
expect(error).toBeInstanceOf(AxiosError);
19+
expect(error.message).toBe('Request failed with status code 404');
20+
expect(error.response.status).toBe(404);
21+
}
22+
});

0 commit comments

Comments
 (0)