1.0.6 • Published 2 years ago

eslint-plugin-angular-test-ids v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

angular-template-test-ids

Requires 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:

<button data-test="my-test-id"></button>
<button [data-test]="myTestId"></button>

Usage

Requires eslint and eslint-plugin-angular to be installed.

npm install --save-dev eslint-plugin-angular-test-ids

In your .eslintrc file add plugin and rule.

Assuming you've previously set up @angular-eslint/template:

{
  "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:

{
  "files": ["*.html"],
  "parser": "@angular-eslint/template-parser",
  "plugins": ["angular-test-ids"],
  "rules": {
    "angular-test-ids/require-test-id": ["error"],
  }
}

Options

OptionDescription
attributeAttribute to look for. Defaults to data-test.
overrideElementsReplace default list of elements that require test ids. Default elements are: Native: <button>, <tr>, <input>, <select>, <textarea>, <option> Material: <mat-radio-group>, <mat-radio-button>, <mat-checkbox>, <mat-chip-list>, <mat-chip>, <mat-select>, <mat-option>
addElementsAdds additional elements to the list of elements requiring test ids without replacing defaults.
1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago