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

Fix code example for window:before:load and google analytics stubbing #1454

chrisbreiding opened this issue Feb 27, 2019 · 0 comments


Copy link

@chrisbreiding chrisbreiding commented Feb 27, 2019

The code example here should use the following:

    const ga = cy.stub().as('ga')

    cy.on('window:before:load', (win) => {
      Object.defineProperty(win, 'ga', {
        configurable: false,
        get: () => ga, // always return the stub
        set: () => {} // don't allow actual google analytics to overwrite this property

The current code doesn't work because it throws due to writeable: false when the actual google analytics tried to define

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants