-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(nuxt): Add unstable_sentryBundlerPluginOptions
to module options
#13811
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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 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 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,139 @@ | ||
import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
import type { SentryNuxtModuleOptions } from '../../src/common/types'; | ||
import { getPluginOptions } from '../../src/vite/sourceMaps'; | ||
|
||
describe('getPluginOptions', () => { | ||
beforeEach(() => { | ||
vi.resetModules(); | ||
process.env = {}; | ||
}); | ||
|
||
it('uses environment variables when no moduleOptions are provided', () => { | ||
const defaultEnv = { | ||
SENTRY_ORG: 'default-org', | ||
SENTRY_PROJECT: 'default-project', | ||
SENTRY_AUTH_TOKEN: 'default-token', | ||
}; | ||
|
||
process.env = { ...defaultEnv }; | ||
|
||
const options = getPluginOptions({} as SentryNuxtModuleOptions); | ||
|
||
expect(options).toEqual( | ||
expect.objectContaining({ | ||
org: 'default-org', | ||
project: 'default-project', | ||
authToken: 'default-token', | ||
telemetry: true, | ||
sourcemaps: expect.objectContaining({ | ||
rewriteSources: expect.any(Function), | ||
}), | ||
_metaOptions: expect.objectContaining({ | ||
telemetry: expect.objectContaining({ | ||
metaFramework: 'nuxt', | ||
}), | ||
}), | ||
debug: false, | ||
}), | ||
); | ||
}); | ||
|
||
it('returns default options when no moduleOptions are provided', () => { | ||
const options = getPluginOptions({} as SentryNuxtModuleOptions); | ||
|
||
expect(options.org).toBeUndefined(); | ||
expect(options.project).toBeUndefined(); | ||
expect(options.authToken).toBeUndefined(); | ||
expect(options).toEqual( | ||
expect.objectContaining({ | ||
telemetry: true, | ||
sourcemaps: expect.objectContaining({ | ||
rewriteSources: expect.any(Function), | ||
}), | ||
_metaOptions: expect.objectContaining({ | ||
telemetry: expect.objectContaining({ | ||
metaFramework: 'nuxt', | ||
}), | ||
}), | ||
debug: false, | ||
}), | ||
); | ||
}); | ||
|
||
it('merges custom moduleOptions with default options', () => { | ||
const customOptions: SentryNuxtModuleOptions = { | ||
sourceMapsUploadOptions: { | ||
org: 'custom-org', | ||
project: 'custom-project', | ||
authToken: 'custom-token', | ||
telemetry: false, | ||
sourcemaps: { | ||
assets: ['custom-assets/**/*'], | ||
ignore: ['ignore-this.js'], | ||
filesToDeleteAfterUpload: ['delete-this.js'], | ||
}, | ||
}, | ||
debug: true, | ||
}; | ||
const options = getPluginOptions(customOptions); | ||
expect(options).toEqual( | ||
expect.objectContaining({ | ||
org: 'custom-org', | ||
project: 'custom-project', | ||
authToken: 'custom-token', | ||
telemetry: false, | ||
sourcemaps: expect.objectContaining({ | ||
assets: ['custom-assets/**/*'], | ||
ignore: ['ignore-this.js'], | ||
filesToDeleteAfterUpload: ['delete-this.js'], | ||
rewriteSources: expect.any(Function), | ||
}), | ||
_metaOptions: expect.objectContaining({ | ||
telemetry: expect.objectContaining({ | ||
metaFramework: 'nuxt', | ||
}), | ||
}), | ||
debug: true, | ||
}), | ||
); | ||
}); | ||
|
||
it('overrides options that were undefined with options from unstable_sentryRollupPluginOptions', () => { | ||
const customOptions: SentryNuxtModuleOptions = { | ||
sourceMapsUploadOptions: { | ||
org: 'custom-org', | ||
project: 'custom-project', | ||
sourcemaps: { | ||
assets: ['custom-assets/**/*'], | ||
filesToDeleteAfterUpload: ['delete-this.js'], | ||
}, | ||
}, | ||
debug: true, | ||
unstable_sentryBundlerPluginOptions: { | ||
org: 'unstable-org', | ||
sourcemaps: { | ||
assets: ['unstable-assets/**/*'], | ||
}, | ||
release: { | ||
name: 'test-release', | ||
}, | ||
}, | ||
}; | ||
const options = getPluginOptions(customOptions); | ||
expect(options).toEqual( | ||
expect.objectContaining({ | ||
debug: true, | ||
org: 'unstable-org', | ||
project: 'custom-project', | ||
sourcemaps: expect.objectContaining({ | ||
assets: ['unstable-assets/**/*'], | ||
filesToDeleteAfterUpload: ['delete-this.js'], | ||
rewriteSources: expect.any(Function), | ||
}), | ||
release: expect.objectContaining({ | ||
name: 'test-release', | ||
}), | ||
}), | ||
); | ||
}); | ||
}); |
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.
I used
Options
from@sentry/bundler-plugin-core
first (as this is the type the other plugins inherit from) but this gave me the following build error:The
Options
are defined as interface, but Rollup definesinterface
as reserved name. I think this is related but I couldn't figure out how to fix that.