From 075747673286ba6ac445ab0f8ceba5a660a89c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 23 Sep 2021 17:10:26 +0200 Subject: [PATCH] feat(no-wait-for-snapshot): add to all configs by default BREAKING CHANGE: `no-wait-for-snapshot` is now enabled by default in all configs --- README.md | 2 +- lib/configs/angular.ts | 1 + lib/configs/dom.ts | 1 + lib/configs/react.ts | 1 + lib/configs/vue.ts | 1 + lib/rules/no-wait-for-snapshot.ts | 8 ++++---- tests/__snapshots__/index.test.ts.snap | 4 ++++ 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 76f4b8ae..8b859d8c 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/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][] | | [`testing-library/no-wait-for-multiple-assertions`](./docs/rules/no-wait-for-multiple-assertions.md) | Disallow the use of multiple `expect` calls inside `waitFor` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-wait-for-side-effects`](./docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | -| [`testing-library/no-wait-for-snapshot`](./docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | | +| [`testing-library/no-wait-for-snapshot`](./docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-explicit-assert`](./docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | | [`testing-library/prefer-find-by`](./docs/rules/prefer-find-by.md) | Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | 🔧 | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-presence-queries`](./docs/rules/prefer-presence-queries.md) | Ensure appropriate `get*`/`query*` queries are used with their respective matchers | | | diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index 8d51b982..564f4ee3 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -17,6 +17,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/dom.ts b/lib/configs/dom.ts index 3a31719a..4f776c7f 100644 --- a/lib/configs/dom.ts +++ b/lib/configs/dom.ts @@ -12,6 +12,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', }, diff --git a/lib/configs/react.ts b/lib/configs/react.ts index e2a76b94..9ad4f20f 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -18,6 +18,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index b42f56d9..b860eb07 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -18,6 +18,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/rules/no-wait-for-snapshot.ts b/lib/rules/no-wait-for-snapshot.ts index 0c78f30d..9b7ddd01 100644 --- a/lib/rules/no-wait-for-snapshot.ts +++ b/lib/rules/no-wait-for-snapshot.ts @@ -21,10 +21,10 @@ export default createTestingLibraryRule({ 'Ensures no snapshot is generated inside of a `waitFor` call', category: 'Best Practices', recommendedConfig: { - dom: false, - angular: false, - react: false, - vue: false, + dom: 'error', + angular: 'error', + react: 'error', + vue: 'error', }, }, messages: { diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index 4e12f2a6..53f87f59 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -22,6 +22,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -39,6 +40,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", }, @@ -69,6 +71,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -95,6 +98,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error",