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
@@ -138,10 +138,11 @@ To enable this configuration use the `extends` property in your
138
138
|[no-manual-cleanup](docs/rules/no-manual-cleanup.md)| Disallow the use of `cleanup`|||
139
139
|[no-multiple-assertions-wait-for](docs/rules/no-multiple-assertions-wait-for.md)| Disallow the use of multiple expect inside `waitFor`|||
140
140
|[no-node-access](docs/rules/no-node-access.md)| Disallow direct Node access |![angular-badge][]![react-badge][]![vue-badge][]||
141
-
|[no-render-in-setup](docs/rules/no-render-in-setup.md)| Disallow the use of `render` in setup functions |||
142
141
|[no-promise-in-fire-event](docs/rules/no-promise-in-fire-event.md)| Disallow the use of promises passed to a `fireEvent` method |||
142
+
|[no-render-in-setup](docs/rules/no-render-in-setup.md)| Disallow the use of `render` in setup functions |||
143
143
|[no-side-effects-wait-for](docs/rules/no-side-effects-wait-for.md)| Disallow the use of side effects inside `waitFor`|||
144
144
|[no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md)| Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved`|![dom-badge][]![angular-badge][]![react-badge][]![vue-badge][]||
145
+
|[no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md)| Ensures no snapshot is generated inside of a `waitFor` call |||
145
146
|[prefer-explicit-assert](docs/rules/prefer-explicit-assert.md)| Suggest using explicit assertions rather than just `getBy*` queries |||
146
147
|[prefer-find-by](docs/rules/prefer-find-by.md)| Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries |![dom-badge][]![angular-badge][]![react-badge][]![vue-badge][]|![fixable-badge][]|
147
148
|[prefer-presence-queries](docs/rules/prefer-presence-queries.md)| Enforce specific queries when checking element is present or not |||
@@ -217,7 +218,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
# Ensures no snapshot is generated inside of a `wait` call' (no-wait-for-snapshot)
2
+
3
+
Ensure that no calls to `toMatchSnapshot` or `toMatchInlineSnapshot` are made from within a `waitFor` method (or any of the other async utility methods).
4
+
5
+
## Rule Details
6
+
7
+
The `waitFor()` method runs in a timer loop. So it'll retry every n amount of time.
8
+
If a snapshot is generated inside the wait condition, jest will generate one snapshot per loop.
9
+
10
+
The problem then is the amount of loop ran until the condition is met will vary between different computers (or CI machines). This leads to tests that will regenerate a lot of snapshots until the condition is matched when devs run those tests locally updating the snapshots; e.g devs cannot run `jest -u` locally or it'll generate a lot of invalid snapshots who'll fail during CI.
11
+
12
+
Note that this lint rule prevents from generating a snapshot from within any of the [async utility methods](https://testing-library.com/docs/dom-testing-library/api-async).
0 commit comments