-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c9a0e08
test(node): Add utility to test esm & cjs instrumentation
mydea 88eee44
add more tests
mydea fb38aed
WIP
mydea 6d1a73c
update ai test
mydea 4e41faf
update timeout
mydea 68ac69e
increase anr timeout
mydea 616c391
rename to failsOnEsm
mydea 68d0733
genericPool
mydea d058fa8
httpIntegration
mydea 05e2692
kafkajs
mydea 1175539
always create files even if cjs is skipped
mydea fffc2c2
remove one level of nesting of describe calls
mydea 3d9ce14
knex
mydea 410cecf
cleanup unneeded comments/vars
mydea 2804ee5
move cjs creation to beforeAll
mydea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
suites/**/tmp_* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
dev-packages/node-integration-tests/suites/anr/basic-multiple.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dev-packages/node-integration-tests/suites/contextLines/filename-with-spaces/instrument.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dev-packages/node-integration-tests/suites/esm/modules-integration/app.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
dev-packages/node-integration-tests/suites/esm/warn-esm/server.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
dev-packages/node-integration-tests/suites/express/with-http/scenario.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
41 changes: 41 additions & 0 deletions
41
dev-packages/node-integration-tests/suites/express/with-http/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ckages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
dev-packages/node-integration-tests/suites/tracing/ai/scenario.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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...