Cypress.io可以测试chrome扩展吗?

Cypress.io可以测试chrome扩展吗?,cypress,end-to-end,Cypress,End To End,我正在尝试使用cypress.io测试我的chrome扩展 我安装了 它不起作用。该页内容如下: Sorry, we could not load: chrome-extension://fmnignchafknmcleldmndpkfkdohnngn/dashboard.html 您不需要任何额外的插件来加载浏览器扩展,假设您运行的是Cypress>v4,下面的内容应该足以加载它 // cypress/plugins/index.js module.exports = (on, config

我正在尝试使用cypress.io测试我的chrome扩展

我安装了

它不起作用。该页内容如下:

Sorry, we could not load: chrome-extension://fmnignchafknmcleldmndpkfkdohnngn/dashboard.html

您不需要任何额外的插件来加载浏览器扩展,假设您运行的是Cypress>v4,下面的内容应该足以加载它

// cypress/plugins/index.js
module.exports = (on, config) => {
  on('before:browser:launch', (browser, launchOptions) => {
    // supply the absolute path to an unpacked extension's folder
    // NOTE: extensions cannot be loaded in headless Chrome
    launchOptions.extensions.push('Users/jane/path/to/extension')

    return launchOptions
  })
}
在您的测试文件中,您可以访问任何“普通”网页,它应该适合您。例如:

// test.spec.js
describe('Navigation', () => {
  it('cy.visit() - visit a remote url', () => {
    cy.visit('https://en.wikipedia.org/wiki/Diabetes')
  })
})
此外,Cypress不能访问诸如“chrome扩展名://”(或任何不是“http”或“https”的内容)。这是他们的设计

// test.spec.js
describe('Navigation', () => {
  it('cy.visit() - visit a remote url', () => {
    cy.visit('https://en.wikipedia.org/wiki/Diabetes')
  })
})