赛普拉斯抛出SecurityError [英] Cypress throwing SecurityError
问题描述
我当前正在与Chrome 74一起运行,并试图使用赛普拉斯来测试我的应用程序中的样式指南。当我加载赛普拉斯时,它将引发以下错误:
I am currently running with Chrome 74 and trying to use Cypress to test a style-guide in my app. When I load up Cypress it throws this error:
SecurityError:阻止了源为 http:// localhost:3000的帧访问跨域框架。
请告诉我是否有解决方案!
Please let me know if there is a solution to this!
我尝试与此同时进行:
https://github.com/cypress-io/cypress/issues/1951
I had tried to follow along with this: https://github.com/cypress-io/cypress/issues/1951
但没有任何变化/有效我。 :(
But nothing has changed/worked for me. :(
我的代码如下所示: cypress / plugins / index.js
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => {
// browser will look something like this
// {
// name: 'chrome',
// displayName: 'Chrome',
// version: '63.0.3239.108',
// path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
// majorVersion: '63'
// }
if (browser.name === 'chrome') {
args.push('--disable-site-isolation-trials');
return args
}
if (browser.name === 'electron') {
args['fullscreen'] = true
// whatever you return here becomes the new args
return args
}
})
}
在我的柏树中/ s upport / index.js
这将在每次运行测试之前加载网站,从而避免每次测试都必须编写cy.visit
This will load the site before every test I run to save myself from having to write cy.visit in every test.
beforeEach(() =>{
cy.visit('http://localhost:3000/style-guide')
})
推荐答案
昨天我遇到了同样的问题,而柏树@jsjoeio 给出了答案>您在问题中引用的#1951 确实对我有所帮助。
I had the very same issue yesterday and the answer from @jsjoeio in the cypress issue #1951 you've referenced in your question actually helped me.
因此,基本上我所做的只是修改 cypress.json
并添加以下值:
So basically only thing I've done was to modify my cypress.json
and add following value:
{
"chromeWebSecurity": false
}
这篇关于赛普拉斯抛出SecurityError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!