Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Nuxt] Disable Sentry module by adding sentry.enabled to Nuxt config #14935

Copy link
Copy link
@Kapcash

Description

@Kapcash
Issue body actions

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',
},
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

No status
Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.