Skip to content

Commit

Permalink
Playwright tests should not send sentry events (#75)
Browse files Browse the repository at this point in the history
* fix: ensure that sentry events are never sent during testing
* fix: do not commit temp vite.config
  • Loading branch information
pajotg authored Jun 6, 2024
1 parent e1d034c commit 0031cd3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ dist-ssr
/playwright-report/
/blob-report/
/playwright/.cache/

vite.config.ts.timestamp*.mjs
10 changes: 1 addition & 9 deletions tests/user_feedback.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from "@playwright/test";
import { goToHomePage, openExample } from "./utils";
import { goToHomePage } from "./utils";

test.beforeEach(goToHomePage);

Expand All @@ -12,14 +12,6 @@ test("User Feedback", async ({ page }) => {
await page.getByPlaceholder("Email").fill("test@ing");
await page.locator("textarea").fill("test123");

// Make sure no requests are actually done
await page.route("**/api/2/envelope/*", (route) => {
route.fulfill({
status: 200,
body: "",
});
});

// Wait for the user_report feedback
const feedbackPromise = page.waitForRequest((request) => {
if (!/.*\/api\/2\/envelope\/.*/.test(request.url())) {
Expand Down
11 changes: 10 additions & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { promises as fs } from "node:fs";
import setupPlaywrightArduino from "@leaphy-robotics/playwright-arduino";
import type { Page, PlaywrightTestArgs } from "@playwright/test";
import { type Page, type PlaywrightTestArgs, test } from "@playwright/test";

// Prevent sentry events from actually being sent
test.beforeEach(async ({ context }) => {
await context.route("**/api/2/envelope/*", (route) => {
route.fulfill({
status: 200,
});
});
});

export async function setupArduino({ page }: PlaywrightTestArgs) {
await setupPlaywrightArduino(page);
Expand Down

0 comments on commit 0031cd3

Please sign in to comment.