garris / BackstopJS

Catch CSS curve balls.
http://backstopjs.org
MIT License
6.67k stars 605 forks source link

Stop tests from triggering google analytics #1443

Open bjornlauwerijs opened 1 year ago

bjornlauwerijs commented 1 year ago

Tried searching for a way to stop triggering google analytics on every scenario that gets run () having three different viewports also triggers a visitor for each test). This is probably an easy thing to do, but not really succeeding in this.

I sadly do not have any way to exclude my local machine from the google analytics.

I tried adding following in playwright/onBefore.js but this is unsuccessful. Any tips?

browserContext.route('*.google-analytics.com', request => request.abort());

fuhlig commented 1 year ago

I am setting a custom userAgent which is excluded within analytics

e.g.

// onBefore scripts

module.exports = async (page) => {
    // Set user agent to identify test and ignore in analytics
    await page.setUserAgent('test/Crawler_Exclude/visual-regression-testing);
};