Eslint rule that enforces test-id attributes on elements in Angular templates.
npm install eslint-plugin-angular-test-idsRequires certain elements to have a test id attribute in template.
Through author of this plugin is not a fan of test ids and thinks user visible labels should be preferred, test ids may be required by your QA team.
Valid code:
``html`
Requires eslint and eslint-plugin-angular to be installed.
`bash`
npm install --save-dev eslint-plugin-angular-test-ids.eslintrc
In your file add plugin and rule.
Assuming you've previously set up @angular-eslint/template:
`json`
{
"files": ["*.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"plugins": ["angular-test-ids"],
"rules": {
"angular-test-ids/require-test-id": ["error"],
... other template rules ...
}
}
If you don't use @angular-eslint/template:
`json`
{
"files": ["*.html"],
"parser": "@angular-eslint/template-parser",
"plugins": ["angular-test-ids"],
"rules": {
"angular-test-ids/require-test-id": ["error"],
}
}
. |
| overrideElements | Replace default list of elements that require test ids.
Default elements are:
Native: