diff --git a/README.md b/README.md index 92435bfa..2079c42a 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/no-node-access`](./docs/rules/no-node-access.md) | Disallow direct Node access | | ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-promise-in-fire-event`](./docs/rules/no-promise-in-fire-event.md) | Disallow the use of promises passed to a `fireEvent` method | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-render-in-setup`](./docs/rules/no-render-in-setup.md) | Disallow the use of `render` in testing frameworks setup functions | | | -| [`testing-library/no-unnecessary-act`](./docs/rules/no-unnecessary-act.md) | Disallow wrapping Testing Library utils or empty callbacks in `act` | | | +| [`testing-library/no-unnecessary-act`](./docs/rules/no-unnecessary-act.md) | Disallow wrapping Testing Library utils or empty callbacks in `act` | | ![react-badge][] | | [`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` | | | | [`testing-library/no-wait-for-side-effects`](./docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | | | diff --git a/lib/configs/react.ts b/lib/configs/react.ts index b2161875..82d2090c 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -13,6 +13,7 @@ export = { 'testing-library/no-dom-import': ['error', 'react'], 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', + 'testing-library/no-unnecessary-act': ['error', { isStrict: true }], 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', diff --git a/lib/rules/no-unnecessary-act.ts b/lib/rules/no-unnecessary-act.ts index 4f4f68d4..8fc06f67 100644 --- a/lib/rules/no-unnecessary-act.ts +++ b/lib/rules/no-unnecessary-act.ts @@ -27,7 +27,7 @@ export default createTestingLibraryRule({ recommendedConfig: { dom: false, angular: false, - react: false, + react: ['error', { isStrict: true }], vue: false, }, }, diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index d154465d..aaa8b910 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -54,6 +54,12 @@ Object { ], "testing-library/no-node-access": "error", "testing-library/no-promise-in-fire-event": "error", + "testing-library/no-unnecessary-act": Array [ + "error", + Object { + "isStrict": true, + }, + ], "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error",