Description
Problem Statement
Context
When running unit tests using the defineVitestConfig
method from @nuxt/test-utils/config
package, it will read the nuxt.config.ts
file and setup the @sentry/nuxt
module if found in the modules
array.
This causes the sentry vite plugin to boot and it logs warnings from sentry:
[Sentry] Enabled source map generation in the build options with `nitro.rollupConfig.output.sourcemap: hidden`.
module.mjs:367
[Sentry] Disabled source map setting in the Nuxt config: `nitro.rollupConfig.output.sourcemapExcludeSources`. Source maps will include the actual code to be able to un-minify code snippets in Sentry.
module.mjs:343
[Sentry] Setting `sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [".*/**/public/**/*.map"]` to delete generated source maps after they were uploaded to Sentry.
module.mjs:227
[sentry-rollup-plugin] Warning: No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-rollup-plugin] Warning: No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-vite-plugin] Warning: No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-vite-plugin] Warning: No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-vite-plugin] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.
Note: the "No auth token provided" warning is because the environment variable I configured is not available in test mode.
Expected behaviour
I want to be able to disable the Sentry module during test mode, so I don't have these logs everytime I run the tests, and also because it seems like Sentry is gonna run along with my tests, which I don't really want.
A workaround I found is to conditionally add the module depending on the NODE_ENV variable:
// nuxt.config.ts
modules: [
process.env.NODE_ENV !== 'test' && '@sentry/nuxt/module',
],
Doing so, the module is not added and therefore not setup in my test environment.
Solution Brainstorm
Maybe simply an enabled
configuration boolean on the module so we can opt-out conditionally?
// nuxt.config.ts
sentry: {
enabled: process.env.NODE_ENV !== 'test',
},
Metadata
Metadata
Assignees
Labels
Type
Projects
Status