Skip to content

Commit

Permalink
insert page.route statement into beforeEach function of playwright te…
Browse files Browse the repository at this point in the history
…st files to abort requests to google analytics
  • Loading branch information
LeoBonjo committed Nov 26, 2024
1 parent 7c61ef7 commit ffc390e
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 2 deletions.
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
3 changes: 2 additions & 1 deletion tests/visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test.describe('Visual Tests', () => {
{ width: 1280, height: 720, name: 'safari' },
{ width: 375, height: 667, name: 'chrome' },
{
iosDeviceInfo: { deviceName: 'iPhone 11' },
iosDeviceInfo: { deviceName: 'iPhone 16' },
},
],
})
Expand All @@ -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 ffc390e

Please sign in to comment.