mindparse
mindparse

Reputation: 7255

Cypress - reCaptcha load error: Refused to load the script because it violates the following Content Security Policy directive

I am needing to get a reCaptcha token for my site key as part of some data setup steps in a test scenario.

I am using cucumber step definitions, and have the following:

import { load } from 'recaptcha-v3'

Then('retrieve reCaptacha token', function () {
  load('<sitekey>').then((recaptcha) => {
    cy.log(recaptcha.getSiteKey())
    recaptcha
      .execute('submit')
      .then((token) => {
        cy.log(token);
      }).catch((err) => {
        cy.log(err)
      });
  }).catch((err) => {
    cy.log(err)
  })
});

When Cypress invokes this, I see the following error:

Refused to load the script 'https://www.google.com/recaptcha/api.js?render=explicit' because it violates the following Content Security Policy directive: "script-src 'unsafe-eval'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

I suspect I am mis-using this somehow inside the Cypress test runner, what do I need to do to get past this?

Upvotes: 0

Views: 121

Answers (0)

Related Questions