accessibility - 使用 cypress-axe 测试可访问性
问题描述
我正在尝试将 cypress-axe包集成到我的项目中。安装 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);
}
});
在规范文件中,注入 ax 如下:
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() is not a function。
谢谢
解决方案
推荐阅读
- xamarin.forms - SQLite Xamarin.forms 不返回保存的数据
- python - 解释 ANN 结果 -> MSE、MAE 和未显示的 epochs 结果
- delphi-7 - Unit1.pas(72): 'END' 预期但 'ELSE' 被发现
- javascript - 将强制布局从 D3.js v3 转换为 v5
- android - 使用 ARM 为 Surface RT 编译 android x86?
- apache - 处理多个域而无需重新启动 HTTP 服务器
- c++ - 为什么在 stl 中使用 bitset 时出现 SIGABRT 错误?
- python - 如何使用 Python 下载此图像?
- python - 遍历后如何按属性过滤neomodel节点?
- entity-framework - 按布尔属性分组在 EF Core 中不起作用