Skip to content

Commit

Permalink
fix: disable sentry in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Feb 10, 2025
1 parent 9ab8719 commit 015b0c9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/review-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
echo "$SITE_URL"
- name: Cypress run
uses: cypress-io/github-action@v5
env:
CYPRESS: "true"
with:
install: false
working-directory: ./packages/app
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
echo "$SITE_URL"
- name: Cypress run
uses: cypress-io/github-action@v5
env:
CYPRESS: "true"
with:
install: false
working-directory: ./packages/app
Expand Down
12 changes: 11 additions & 1 deletion packages/app/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ import { replayIntegration } from "@sentry/nextjs";
const ENVIRONMENT = process.env.NEXT_PUBLIC_EGAPRO_ENV || "development";
const IS_PRODUCTION = ENVIRONMENT === "production";

// Declare Cypress on window for TypeScript
declare global {
interface Window {
Cypress?: unknown;
}
}

// Disable Sentry during Cypress tests
const isCypressTest = typeof window !== "undefined" && window.Cypress !== undefined;

Sentry.init({
// Basic configuration
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
dsn: isCypressTest ? undefined : process.env.NEXT_PUBLIC_SENTRY_DSN, // Disable Sentry in Cypress by setting DSN to undefined
environment: ENVIRONMENT,
debug: true, // Temporarily enable debug mode to troubleshoot
dist: process.env.NEXT_PUBLIC_GITHUB_SHA || "dev",
Expand Down
5 changes: 4 additions & 1 deletion packages/app/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import * as Sentry from "@sentry/nextjs";
const ENVIRONMENT = process.env.NEXT_PUBLIC_EGAPRO_ENV || "development";
const IS_PRODUCTION = ENVIRONMENT === "production";

// Check for Cypress test environment
const isCypressTest = process.env.CYPRESS === "true";

Sentry.init({
// Basic configuration
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
dsn: isCypressTest ? undefined : process.env.NEXT_PUBLIC_SENTRY_DSN, // Disable Sentry in Cypress
environment: ENVIRONMENT,
debug: true, // Temporarily enable debug mode to troubleshoot
dist: process.env.NEXT_PUBLIC_GITHUB_SHA || "dev",
Expand Down

0 comments on commit 015b0c9

Please sign in to comment.