Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test | block google analytics when running tests #829

Closed
NoamGaash opened this issue Jun 20, 2024 · 6 comments · Fixed by #951
Closed

test | block google analytics when running tests #829

NoamGaash opened this issue Jun 20, 2024 · 6 comments · Fixed by #951
Labels
ci improvements to our CI pipeline frontend frontend developers issue good first issue Good for newcomers hacktoberfest tests

Comments

@NoamGaash
Copy link
Member

NoamGaash commented Jun 20, 2024

When running playwright test, let's use page.route to abort all requests to google analytics

@NoamGaash NoamGaash added ci improvements to our CI pipeline frontend frontend developers issue tests good first issue Good for newcomers labels Jun 20, 2024
@YaelChen
Copy link
Collaborator

Does it only mean to add this line
await page.route('**/*google-analytics*', route => route.abort());
to every test file under "beforeEach"?

I'd like to assign myself if so.

@NoamGaash
Copy link
Member Author

@YaelChen I think there are some domains that we would like to block, while avoid blocking unrelated urls
Using the Chrome DevTool can help determine which URLs should be blocked:
image
And the test you've added that clicks this link is expected to pass despite of this change:
image

Thank you! 🙏

@YaelChen
Copy link
Collaborator

I see the logic 😅
Thanks! I'll need to investigate some more for this,
So I'm not assigning yet so that someone else will be able to take it :)

@LeoBonjo
Copy link
Collaborator

Does it only mean to add this line await page.route('**/*google-analytics*', route => route.abort()); to every test file under "beforeEach"?

I'd like to assign myself if so.

@YaelChen Hello, I had the same idea! However, when I open local host, it looks like the requests are still being sent. They return 204 No Content, regardless of whether I put in the await page.route('**/*google-analytics*', route => route.abort());.

Screenshot 2024-11-21 at 11 16 28 AM

I also tried creating a global-setup for playwright, but same thing. I am somewhat baffled. If you make any progress I'd be very excited to see :)

@NoamGaash
Copy link
Member Author

NoamGaash commented Nov 22, 2024

I believe that the command await page.route('**/*google-analytics*', route => route.abort()); use a wrong pattern.
something like:

page.route(/google-analytics\.com|googletagmanager\.com/, route => route.abort());

or

page.route(/^https?:\/\/(google-analytics|googletagmanager).com/, route => route.abort());

would probably do the trick

@NoamGaash NoamGaash linked a pull request Dec 2, 2024 that will close this issue
@NoamGaash
Copy link
Member Author

closed by @LeoBonjo in #951 - Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci improvements to our CI pipeline frontend frontend developers issue good first issue Good for newcomers hacktoberfest tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants