我正在尝试将柏树package集成到我的项目中。安装cypress-axe和axe-core库之后。我已在 cypress \ support \ index.js 中将 cypress-axe 导入如下:
// Import commands.js using ES2015 syntax:
import '@cypress/code-coverage/support'
import './commands'
import 'cypress-axe'
Cypress.on('uncaught:exception', () => {
// returning false here prevents Cypress from
// failing the test
return false
})
Cypress.on('window:before:unload', e => {
const coverage = e.currentTarget.__coverage__;
if (coverage) {
map.merge(coverage);
}
});
在spec文件中,如下所示插入了斧头:
before(() => {
cy.visit(url);
cy.injectAxe();
});
describe('Initial state of component', () => {
it('Has no detectable a11y violations on load', () => {
// Test the page at initial load
cy.checkA11y()
})
})
但是当我运行cypress测试时,出现错误 cy.injectAxe()不是函数。
谢谢