'Cypress shows the JS window._tcfapi error which I cannot reproduce from manual testing

Cypress test which reproduce this error https://github.com/Robot72/quantcast-cypress-issue/blob/master/cypress/integration/quantcast/check_errors.spec.js

This test code:

context('Navigation to our website', () => {
  it('Visit and check quantcast has error or not', () => {
    cy.visit('https://www.nanoresort.com/stories/celebrities-lost-money-can-no-longer-afford-extravagant-lifestyles/');
  })
})

The Screenshot shows this issue window._tcfapi error

If I open this link from test in my browser then I do not see this window.__tcfapi error. I can reproduce this error from cypress for any other websites which using quantcast library but I do not see this from my browser without cypress.

Could you help me to understand why I have this error when cypress run this test?



Solution 1:[1]

If you don’t need to call the Quantcast api, you can fix it by just blocking the script domains in your cypress.json

{
  "blockHosts": [
    "*.quantserve.com",
    "*.consensu.org"
  ]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Patrik Hol?ák