-
-
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
+356
−82
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a42772a
test(bun, deno): Run shared Node integration suites on Bun and Deno
JPeer264 2c9474d
fixup! test(bun, deno): Run shared Node integration suites on Bun and…
JPeer264 5948ee0
fixup! test(bun, deno): Run shared Node integration suites on Bun and…
JPeer264 a74de0d
fixup! test(bun, deno): Run shared Node integration suites on Bun and…
JPeer264 e6d12df
fixup! test(bun, deno): Run shared Node integration suites on Bun and…
JPeer264 2b21694
fixup! test(bun, deno): Run shared Node integration suites on Bun and…
JPeer264 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
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
| 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. | ||
| // Dependencies in `node_modules` are skipped: Bun treats a module returned from `onLoad` as async, | ||
| // and a CommonJS `require()` of it then fails. | ||
| const NODE_SUITE_ESM_FILE = | ||
| /[\\/]node-integration-tests[\\/](suites|utils)[\\/](?!(?:.*[\\/])?node_modules[\\/]).*\.(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,45 @@ | ||
| 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', | ||
| ], | ||
| // 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)), | ||
| }, | ||
| // Above the 30 second port timeout of the runner on Deno, so a slow start can still pass. | ||
| testTimeout: 45_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.
Uh oh!
There was an error while loading. Please reload this page.