-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
test(bun, deno): Run shared Node integration suites on Bun and Deno #24609
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
Open
+350
−82
Open
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions
32
dev-packages/bun-integration-tests/node-suites/alias-sentry-bun.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,32 @@ | ||
| import { plugin } from 'bun'; | ||
| import Module from 'node:module'; | ||
|
|
||
| // Maps `@sentry/node` to `@sentry/bun` in the Node suite files. `@sentry/bun` imports | ||
| // `@sentry/node` itself, so imports from outside the Node suite files are not touched. | ||
| const NODE_SUITE_FILE = /[\\/]node-integration-tests[\\/](suites|utils)[\\/]/; | ||
|
|
||
| // Bun's runtime `onResolve` does not see bare package specifiers, so ES modules are rewritten on | ||
| // load. `onLoad` output for a CommonJS file does not run, so those files keep their source. | ||
| const NODE_SUITE_ESM_FILE = /[\\/]node-integration-tests[\\/](suites|utils)[\\/].*\.(mjs|ts)$/; | ||
| const SENTRY_NODE_SPECIFIER = /(['"])@sentry\/node\1/g; | ||
|
|
||
| plugin({ | ||
| name: 'alias-sentry-node-to-sentry-bun', | ||
| setup(build) { | ||
| build.onLoad({ filter: NODE_SUITE_ESM_FILE }, async args => { | ||
| const source = await Bun.file(args.path).text(); | ||
| return { | ||
| contents: source.replace(SENTRY_NODE_SPECIFIER, '$1@sentry/bun$1'), | ||
| loader: args.path.endsWith('.ts') ? 'ts' : 'js', | ||
| }; | ||
| }); | ||
| }, | ||
| }); | ||
|
|
||
| type ResolveFilename = (request: string, parent: { filename?: string } | undefined, ...rest: unknown[]) => string; | ||
| const moduleWithResolve = Module as unknown as { _resolveFilename: ResolveFilename }; | ||
| const originalResolveFilename = moduleWithResolve._resolveFilename; | ||
| moduleWithResolve._resolveFilename = function (request, parent, ...rest) { | ||
| const aliased = request === '@sentry/node' && NODE_SUITE_FILE.test(parent?.filename ?? '') ? '@sentry/bun' : request; | ||
| return originalResolveFilename.call(this, aliased, parent, ...rest); | ||
| }; | ||
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
5 changes: 5 additions & 0 deletions
5
dev-packages/deno-integration-tests/node-suites/import-map.json
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,5 @@ | ||
| { | ||
| "imports": { | ||
| "@sentry-internal/node-integration-tests": "../../node-integration-tests/build/esm/index.js" | ||
| } | ||
| } |
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,44 @@ | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { defineConfig } from 'vitest/config'; | ||
| import baseConfig from '../../vite/vite.config'; | ||
|
|
||
| // Runs the Node suites below on Deno. The scenarios stay in `node-integration-tests`, and the | ||
| // Deno-only suites in `suites/` run with `deno test`. | ||
| export default defineConfig({ | ||
| ...baseConfig, | ||
| test: { | ||
| ...baseConfig.test, | ||
| root: fileURLToPath(new URL('../node-integration-tests', import.meta.url)), | ||
| coverage: { | ||
| enabled: false, | ||
| }, | ||
| isolate: false, | ||
| include: [ | ||
| 'suites/public-api/**/test.ts', | ||
| 'suites/client-reports/**/test.ts', | ||
| 'suites/featureFlags/**/test.ts', | ||
| 'suites/express/tracing/**/test.ts', | ||
| 'suites/tracing/httpIntegration/test.ts', | ||
| 'suites/tracing/httpIntegration-streamed/test.ts', | ||
|
Comment on lines
+20
to
+22
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. low/nit/question, the PR description says that it only opts into the first three, but this is more stuff? I think it's probably best to have them in, but maybe update the description and commit message before landing. |
||
| ], | ||
| // Single tests that fail on Deno are skipped with `test.skipIf` on `RUNTIME` in the Node suite. | ||
| exclude: ['**/node_modules/**'], | ||
| env: { | ||
| RUNTIME: 'deno', | ||
| DENO_IMPORT_MAP: fileURLToPath(new URL('./node-suites/import-map.json', import.meta.url)), | ||
| }, | ||
| testTimeout: 15_000, | ||
| ...(process.env.DEBUG | ||
| ? { | ||
| disableConsoleIntercept: true, | ||
| silent: false, | ||
| } | ||
| : {}), | ||
| pool: 'threads', | ||
| reporters: process.env.DEBUG | ||
| ? ['default', { summary: false }] | ||
| : process.env.GITHUB_ACTIONS | ||
| ? ['dot', 'github-actions'] | ||
| : ['verbose'], | ||
| }, | ||
| }); | ||
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
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.
Would be good to exclude the deps that get installed in these.