-
Notifications
You must be signed in to change notification settings - Fork 52
test: New integration tests #896
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
Changes from all commits
60ddcf3
91a1ac7
e93d586
61b1a36
c182d26
0fc97ee
5eea904
22d4fe6
457e22a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "editor.defaultFormatter": "oxc.oxc-vscode", | ||
| "editor.defaultFormatter": "oxc.oxc-vscode" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,6 +119,15 @@ export function makeOptionallyEnabledNodeTransport( | |
| } | ||
|
|
||
| if (await shouldSendTelemetry) { | ||
| if (process.env["SENTRY_TEST_OUT_DIR"]) { | ||
| // eslint-disable-next-line @typescript-eslint/unbound-method | ||
| const { join } = await import("node:path"); | ||
| const { appendFileSync } = await import("node:fs"); | ||
| const path = join(process.env["SENTRY_TEST_OUT_DIR"], "sentry-telemetry.json"); | ||
| appendFileSync(path, JSON.stringify(request) + ",\n"); | ||
| return { statusCode: 200 }; | ||
timfish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
Comment on lines
+122
to
+129
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. q: Not blocking but would there be a way around this?
Collaborator
Author
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. I tried a mock server but spent too long trying to get it working and then found we already did something similar above for the existing integration tests. I will revisit this though! |
||
|
|
||
| return nodeTransport.send(request); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /** @type {import('eslint').ESLint.Options} */ | ||
| module.exports = { | ||
| root: true, | ||
| extends: ["@sentry-internal/eslint-config/base"], | ||
| ignorePatterns: [".eslintrc.js", "fixtures/*/out", "fixtures/*/src"], | ||
| parserOptions: { | ||
| tsconfigRootDir: __dirname, | ||
| project: ["./tsconfig.json"], | ||
| }, | ||
| env: { | ||
| node: true, | ||
| }, | ||
| rules: { | ||
| "@typescript-eslint/explicit-function-return-type": "off", | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| fixtures/*/out/** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { sentryRollupPlugin } from "@sentry/rollup-plugin"; | ||
| import { defineConfig } from "rolldown"; | ||
|
|
||
| export default defineConfig({ | ||
| input: "src/basic.js", | ||
| output: { | ||
| file: "out/after-upload-deletion/basic.js", | ||
| sourcemap: true, | ||
| }, | ||
| plugins: [ | ||
| sentryRollupPlugin({ | ||
| telemetry: false, | ||
| sourcemaps: { | ||
| filesToDeleteAfterUpload: ["out/after-upload-deletion/basic.js.map"], | ||
| }, | ||
| }), | ||
| ], | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { expect } from "vitest"; | ||
| import { test } from "./utils"; | ||
|
|
||
| test(import.meta.url, ({ runRolldown, readOutputFiles, runFileInNode }) => { | ||
| runRolldown(); | ||
| expect(readOutputFiles()).toMatchInlineSnapshot(` | ||
| { | ||
| "basic.js": "//#region src/basic.js | ||
| !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b699d9c1-b033-4536-aa25-233c92609b54",e._sentryDebugIdIdentifier="sentry-dbid-b699d9c1-b033-4536-aa25-233c92609b54");}catch(e){}}();console.log("hello world"); | ||
|
|
||
| //#endregion | ||
| //# sourceMappingURL=basic.js.map", | ||
| } | ||
| `); | ||
|
|
||
| const output = runFileInNode("basic.js"); | ||
| expect(output).toBe("hello world\n"); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { sentryRollupPlugin } from "@sentry/rollup-plugin"; | ||
| import { defineConfig } from "rolldown"; | ||
|
|
||
| export default defineConfig({ | ||
| input: "src/basic.js", | ||
| output: { | ||
| file: "out/application-key/basic.js", | ||
| }, | ||
| plugins: [sentryRollupPlugin({ telemetry: false, applicationKey: "1234567890abcdef" })], | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { expect } from "vitest"; | ||
| import { test } from "./utils"; | ||
|
|
||
| test(import.meta.url, ({ runRolldown, readOutputFiles }) => { | ||
| runRolldown(); | ||
| expect(readOutputFiles()).toMatchInlineSnapshot(` | ||
| { | ||
| "basic.js": "//#region src/basic.js | ||
| !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],{"_sentryBundlerPluginAppKey:1234567890abcdef":true});var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b699d9c1-b033-4536-aa25-233c92609b54",e._sentryDebugIdIdentifier="sentry-dbid-b699d9c1-b033-4536-aa25-233c92609b54");}catch(e){}}();console.log("hello world"); | ||
|
|
||
| //#endregion", | ||
| } | ||
| `); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { sentryRollupPlugin } from "@sentry/rollup-plugin"; | ||
| import { defineConfig } from "rolldown"; | ||
|
|
||
| export default defineConfig({ | ||
| input: "src/basic.js", | ||
| output: { | ||
| file: "out/basic-release-disabled/basic.js", | ||
| }, | ||
| plugins: [sentryRollupPlugin({ telemetry: false, release: { create: false, inject: false } })], | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { expect } from "vitest"; | ||
| import { test } from "./utils"; | ||
|
|
||
| test(import.meta.url, ({ runRolldown, readOutputFiles }) => { | ||
| runRolldown(); | ||
| expect(readOutputFiles()).toMatchInlineSnapshot(` | ||
| { | ||
| "basic.js": "//#region src/basic.js | ||
| !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b699d9c1-b033-4536-aa25-233c92609b54",e._sentryDebugIdIdentifier="sentry-dbid-b699d9c1-b033-4536-aa25-233c92609b54");}catch(e){}}();console.log("hello world"); | ||
|
|
||
| //#endregion", | ||
| } | ||
| `); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { sentryRollupPlugin } from "@sentry/rollup-plugin"; | ||
| import { defineConfig } from "rolldown"; | ||
|
|
||
| export default defineConfig({ | ||
| input: "src/basic.js", | ||
| output: { | ||
| file: "out/basic-sourcemaps/basic.js", | ||
| sourcemap: true, | ||
| }, | ||
| plugins: [ | ||
| sentryRollupPlugin({ | ||
| telemetry: false, | ||
| authToken: "fake-auth", | ||
| org: "fake-org", | ||
| project: "fake-project", | ||
| }), | ||
| ], | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { expect } from "vitest"; | ||
| import { test } from "./utils"; | ||
|
|
||
| test(import.meta.url, ({ runRolldown, readOutputFiles, runFileInNode }) => { | ||
| runRolldown(); | ||
| expect(readOutputFiles()).toMatchInlineSnapshot(` | ||
| { | ||
| "basic.js": "//#region src/basic.js | ||
| !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b699d9c1-b033-4536-aa25-233c92609b54",e._sentryDebugIdIdentifier="sentry-dbid-b699d9c1-b033-4536-aa25-233c92609b54");}catch(e){}}();console.log("hello world"); | ||
|
|
||
| //#endregion | ||
| //# sourceMappingURL=basic.js.map", | ||
| "basic.js.map": "{"version":3,"file":"basic.js","names":[],"sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"mappings":";scACA,OAAA,CAAQ,GAAA,CAAI,CAAA,KAAA,CAAA,KAAA,CAAA,CAAc"}", | ||
| "sentry-cli-mock.json": "["releases","new","CURRENT_SHA"], | ||
| ["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"], | ||
| ["releases","finalize","CURRENT_SHA"], | ||
| ["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"], | ||
| ", | ||
| } | ||
| `); | ||
|
|
||
| const output = runFileInNode("basic.js"); | ||
| expect(output).toBe("hello world\n"); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { sentryRollupPlugin } from "@sentry/rollup-plugin"; | ||
| import { defineConfig } from "rolldown"; | ||
|
|
||
| export default defineConfig({ | ||
| input: "src/basic.js", | ||
| output: { | ||
| file: "out/basic/basic.js", | ||
| }, | ||
| plugins: [ | ||
| sentryRollupPlugin({ | ||
| telemetry: false, | ||
| authToken: "fake-auth", | ||
| org: "fake-org", | ||
| project: "fake-project", | ||
| }), | ||
| ], | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { expect } from "vitest"; | ||
| import { test } from "./utils"; | ||
|
|
||
| test(import.meta.url, ({ runRolldown, readOutputFiles, runFileInNode }) => { | ||
| runRolldown(); | ||
| expect(readOutputFiles()).toMatchInlineSnapshot(` | ||
| { | ||
| "basic.js": "//#region src/basic.js | ||
| !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b699d9c1-b033-4536-aa25-233c92609b54",e._sentryDebugIdIdentifier="sentry-dbid-b699d9c1-b033-4536-aa25-233c92609b54");}catch(e){}}();console.log("hello world"); | ||
|
|
||
| //#endregion", | ||
| "sentry-cli-mock.json": "["releases","new","CURRENT_SHA"], | ||
| ["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"], | ||
| ["releases","finalize","CURRENT_SHA"], | ||
| ["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"], | ||
| ", | ||
| } | ||
| `); | ||
|
|
||
| const output = runFileInNode("basic.js"); | ||
| expect(output).toBe("hello world\n"); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { sentryRollupPlugin } from "@sentry/rollup-plugin"; | ||
| import { defineConfig } from "rolldown"; | ||
|
|
||
| export default defineConfig({ | ||
| input: "src/basic.js", | ||
| output: { | ||
| file: "out/build-info/basic.js", | ||
| }, | ||
| plugins: [ | ||
| sentryRollupPlugin({ | ||
| telemetry: false, | ||
| release: { | ||
| name: "build-information-injection-test", | ||
| }, | ||
| _experiments: { injectBuildInformation: true }, | ||
| }), | ||
| ], | ||
| }); |
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.
q: That is intentional I guess?
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.
It was intentional but this probably needs revising too.
I was changing the integration tests and re-running and it was hitting the cache.
Should we ever cache test output?
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.
No let's not