我正在尝试将柏树测试集成到我的应用程序中,但是为了执行e2e测试,我需要与元问题交互。我正在使用柏树元插件(https://www.npmjs.com/package/cypress-metamask),但无法让它工作。
运行测试将返回以下错误:
cy.task('setupMetamask')失败,错误如下: 请求http://localhost:9222/json/version失败,原因:连接ECONNREFUSED 127.0.0.1:9222
这是一个考验:
describe('NFTicket', () => {
beforeEach(() => {
cy.setupMetamask();
cy.changeMetamaskNetwork('localhost')
cy.visit('/')
});
it('is expected to display a sussess message', () => {
cy.get('[data-cy=title]').should('contain.text', 'MetaMask Detected')
});
});我的柏树/plugins/index.js就是这样配置的:
module.exports = (on, config) => {
require('cypress-metamask/plugins')(on);
on('before:browser:launch', (browser = { isHeaded: true }, arguments_) => {
if (browser.name === 'chrome') {
arguments_.args.push('--remote-debugging-port=9222')
arguments_.args.push('--disable-background-timer-throttling');
arguments_.args.push('--disable-backgrounding-occluded-windows');
arguments_.args.push('--disable-renderer-backgrounding');
}
})
}发布于 2022-03-05 17:23:23
请确保服务器已经启动,您可以在/etc/host文件中尝试这个127.0.0.1 localhost。
https://stackoverflow.com/questions/71363236
复制相似问题