Skip to content

Commit

Permalink
test: block google analytics when running tests (#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoBonjo authored Nov 27, 2024
1 parent d684b74 commit 964908d
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/about.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect } from './utils'
test.describe('About Page Tests', () => {
test.beforeEach(({ advancedRouteFromHAR }) => {
test.beforeEach(async ({ page, advancedRouteFromHAR }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
advancedRouteFromHAR('tests/HAR/clearbutton.har', {
updateContent: 'embed',
update: false,
Expand Down
1 change: 1 addition & 0 deletions tests/clearButton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async function selectLineNumberAndRoute(page: Page, lineNumber: Locator, route:

test.describe('clearButton functionality', () => {
test.beforeEach(async ({ page, advancedRouteFromHAR }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
await i18next.use(Backend).init({
lng: 'he',
backend: {
Expand Down
1 change: 1 addition & 0 deletions tests/dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { test, urlMatcher } from './utils'

test.describe('dashboard tests', () => {
test.beforeEach(async ({ page, advancedRouteFromHAR }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
advancedRouteFromHAR('tests/HAR/dashboard.har', {
updateContent: 'embed',
update: false,
Expand Down
1 change: 1 addition & 0 deletions tests/mainHeader.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect } from './utils'

test.beforeEach(async ({ page }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
await page.goto('/')
})

Expand Down
1 change: 1 addition & 0 deletions tests/menu.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect, urlMatcher } from './utils'

test.beforeEach(async ({ page, advancedRouteFromHAR }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
advancedRouteFromHAR('tests/HAR/menu.har', {
updateContent: 'embed',
update: false,
Expand Down
1 change: 1 addition & 0 deletions tests/realtimemap.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, urlMatcher } from './utils'

test.beforeEach(async ({ page, advancedRouteFromHAR }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
advancedRouteFromHAR('tests/HAR/realtimemap.har', {
updateContent: 'embed',
update: false,
Expand Down
1 change: 1 addition & 0 deletions tests/singlelineTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test.describe('Single line page tests', () => {
let singleLinePage: SinglelinePage

test.beforeEach(async ({ page, advancedRouteFromHAR }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
advancedRouteFromHAR('tests/HAR/singleline.har', {
updateContent: 'embed',
update: false,
Expand Down
1 change: 1 addition & 0 deletions tests/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test.describe('Timeline Page Tests', () => {
let timelinePage: TimelinePage

test.beforeEach(async ({ page, advancedRouteFromHAR }) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
await i18next.use(Backend).init({
lng: 'he',
backend: {
Expand Down
1 change: 1 addition & 0 deletions tests/visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test.describe('Visual Tests', () => {
})

test.beforeEach(async ({ page }, testinfo) => {
await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort())
if (!process.env.APPLITOOLS_API_KEY) {
eyes.setIsDisabled(true)
console.log('APPLITOOLS_API_KEY is not defined, please ask noamgaash for the key')
Expand Down

0 comments on commit 964908d

Please sign in to comment.