Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
test(node): Add utility to test esm & cjs instrumentation#16159
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
c9a0e0888eee44fb38aed6d1a73c4e41faf68ac69e616c39168d0733d058fa805e26921175539fffc2c23d9ce14410cecf2804ee5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| suites/**/tmp_* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import * as Sentry from '@sentry/node'; | ||
| import { startExpressServerAndSendPortToRunner } from '@sentry-internal/node-integration-tests'; | ||
| import express from 'express'; | ||
| import http from 'http'; | ||
| const app = express(); | ||
| app.get('/test', (_req, res) => { | ||
| http.get(`http://localhost:${app.port}/test2`, httpRes => { | ||
| httpRes.on('data', () => { | ||
| setTimeout(() => { | ||
| res.send({ response: 'response 1' }); | ||
| }, 200); | ||
| }); | ||
| }); | ||
| }); | ||
| app.get('/test2', (_req, res) => { | ||
| res.send({ response: 'response 2' }); | ||
| }); | ||
| app.get('/test3', (_req, res) => { | ||
| res.send({ response: 'response 3' }); | ||
| }); | ||
| Sentry.setupExpressErrorHandler(app); | ||
| startExpressServerAndSendPortToRunner(app); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { afterAll, describe } from 'vitest'; | ||
| import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner'; | ||
| describe('express with http import', () => { | ||
| afterAll(() => { | ||
| cleanupChildProcesses(); | ||
| }); | ||
| createEsmAndCjsTests( | ||
| __dirname, | ||
| 'scenario.mjs', | ||
| 'instrument.mjs', | ||
| (createRunner, test) => { | ||
| test('it works when importing the http module', async () => { | ||
| const runner = createRunner() | ||
| .expect({ | ||
| transaction: { | ||
| transaction: 'GET /test2', | ||
| }, | ||
| }) | ||
| .expect({ | ||
| transaction: { | ||
| transaction: 'GET /test', | ||
| }, | ||
| }) | ||
| .expect({ | ||
| transaction: { | ||
| transaction: 'GET /test3', | ||
| }, | ||
| }) | ||
| .start(); | ||
| await runner.makeRequest('get', '/test'); | ||
| await runner.makeRequest('get', '/test3'); | ||
| await runner.completed(); | ||
| }); | ||
| // TODO: This is failing on ESM because importing http is triggering the http spans twice :( | ||
| // We need to fix this! | ||
| }, | ||
| { failsOnEsm: true }, | ||
| ); | ||
| }); |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated but this flaked some times, let's see if this helps...