You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`2.0.0` - new `onSubmit` rule (thank you @@jzatt), upgrade to ESLint 8 and Mocha 9, fix moderate security advisory for `chalk/ansi-regex`
4
-
-`1.3.0` - Add auto-fix capability to `onClick` (thank you @bkonuwa and @pixelbandito). ([#8](https://github.com/davidcalhoun/eslint-plugin-test-selectors/pull/8))
5
-
-`1.1.0`
6
-
- elements with `disabled` and `readonly` attributes are now ignored by default. See [Custom Rules Options](#custom-rule-options) to customize this behavior. (fixes [#3][i3])
7
-
-`plugin:test-selectors/recommended` now emits warnings by default instead of errors. For the old stricter behavior which emits errors, folks can use `plugin:test-selectors/recommendedWithErrors` (fixes [#4][i4])
8
-
- Refactoring and cleanup. Readme improvements.
9
-
-`1.0.1` - fix bug with inline functions (fixes [#1][i1])
10
-
-`1.0.0` - initial release
3
+
-`2.1.0` - custom `testAttribute` property now accepts arrays. Also fixes vulnerability in word-wrap.
4
+
-`2.0.0` - new `onSubmit` rule (thank you @@jzatt), upgrade to ESLint 8 and Mocha 9, fix moderate security advisory for `chalk/ansi-regex`
5
+
-`1.3.0` - Add auto-fix capability to `onClick` (thank you @bkonuwa and @pixelbandito). ([#8](https://github.com/davidcalhoun/eslint-plugin-test-selectors/pull/8))
6
+
-`1.1.0`
7
+
- elements with `disabled` and `readonly` attributes are now ignored by default. See [Custom Rules Options](#custom-rule-options) to customize this behavior. (fixes [#3][i3])
8
+
-`plugin:test-selectors/recommended` now emits warnings by default instead of errors. For the old stricter behavior which emits errors, folks can use `plugin:test-selectors/recommendedWithErrors` (fixes [#4][i4])
9
+
- Refactoring and cleanup. Readme improvements.
10
+
-`1.0.1` - fix bug with inline functions (fixes [#1][i1])
### Example of eslint-plugin-test-selectors running in Visual Studio Code:
12
11
13
12

14
13
15
-
## Changelog
14
+
## Selected changelog
16
15
17
-
-`2.0.0` - new `onSubmit` rule (thank you @@jzatt), upgrade to ESLint 8 and Mocha 9, fix moderate security advisory for `chalk/ansi-regex`
18
-
-`1.3.0` - Add auto-fix capability to `onClick` (thank you @bkonuwa and @pixelbandito). ([#8](https://github.com/davidcalhoun/eslint-plugin-test-selectors/pull/8))
19
-
-`1.1.0`
20
-
- elements with `disabled` and `readonly` attributes are now ignored by default. See [Custom Rules Options](#custom-rule-options) to customize this behavior. (fixes [#3][i3])
21
-
-`plugin:test-selectors/recommended` now emits warnings by default instead of errors. For the old stricter behavior which emits errors, folks can use `plugin:test-selectors/recommendedWithErrors` (fixes [#4][i4])
22
-
- Refactoring and cleanup. Readme improvements.
23
-
-`1.0.1` - fix bug with inline functions (fixes [#1][i1])
24
-
-`1.0.0` - initial release
16
+
[See full changelog](https://github.com/davidcalhoun/eslint-plugin-test-selectors/blob/main/changelog.md)
17
+
18
+
-`2.1.0` - custom `testAttribute` property now accepts arrays. Also fixes vulnerability in word-wrap.
19
+
-`2.0.0` - new `onSubmit` rule (thank you @@jzatt), upgrade to ESLint 8 and Mocha 9, fix moderate security advisory for `chalk/ansi-regex`
20
+
-`1.3.0` - Add auto-fix capability to `onClick` (thank you @bkonuwa and @pixelbandito). ([#8](https://github.com/davidcalhoun/eslint-plugin-test-selectors/pull/8))
25
21
26
22
## Installation
27
23
@@ -45,15 +41,15 @@ Add `test-selectors` to the plugins section of your `.eslintrc` configuration fi
45
41
46
42
```json
47
43
{
48
-
"plugins": ["test-selectors"]
44
+
"plugins": ["test-selectors"]
49
45
}
50
46
```
51
47
52
48
If you want to use all the recommended default rules, you can simply add this line to the `extends` section of your `.eslintrc` configuration:
53
49
54
50
```json
55
51
{
56
-
"extends": ["plugin:test-selectors/recommended"]
52
+
"extends": ["plugin:test-selectors/recommended"]
57
53
}
58
54
```
59
55
@@ -63,19 +59,19 @@ Another option: you can also selectively enable and disable individual rules in
63
59
64
60
```json
65
61
{
66
-
"rules": {
67
-
"test-selectors/button": ["warn", "always"]
68
-
}
62
+
"rules": {
63
+
"test-selectors/button": ["warn", "always"]
64
+
}
69
65
}
70
66
```
71
67
72
68
If you like most of the recommended rules by adding the `extends` option above, but find one in particular to be bothersome, you can simply disable it:
73
69
74
70
```json
75
71
{
76
-
"rules": {
77
-
"test-selectors/anchor": "off"
78
-
}
72
+
"rules": {
73
+
"test-selectors/anchor": "off"
74
+
}
79
75
}
80
76
```
81
77
@@ -91,40 +87,31 @@ The default test attribute expected is `data-test-id`, but you can override it w
By default all elements with the `disabled` attribute are ignored, e.g. `<input disabled />`. If you don't want to ignore this attribute, set `ignoreDisabled` to `false`:
If you don't want these test attributes added in production, you can use something like [babel-plugin-jsx-remove-data-test-id](https://github.com/coderas/babel-plugin-jsx-remove-data-test-id)
171
156
172
157
Why `data` attributes and not `id` or `class`? Check out some of the following:
173
158
174
-
-[Decoupling CSS Selectors From Your Tests](https://mixandgo.com/learn/decoupling-css-selectors-from-your-tests)
175
-
-[Test your DOM with Data Attributes](https://medium.com/@colecodes/test-your-dom-with-data-attributes-44fccc43ed4b)
176
-
-[Something Better than IDs for Identifying Elements in Selenium Tests](https://techblog.constantcontact.com/software-development/a-better-way-to-id-elements-in-selenium-tests/)
159
+
-[Decoupling CSS Selectors From Your Tests](https://mixandgo.com/learn/decoupling-css-selectors-from-your-tests)
160
+
-[Test your DOM with Data Attributes](https://medium.com/@colecodes/test-your-dom-with-data-attributes-44fccc43ed4b)
161
+
-[Something Better than IDs for Identifying Elements in Selenium Tests](https://techblog.constantcontact.com/software-development/a-better-way-to-id-elements-in-selenium-tests/)
0 commit comments