aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-11 18:59:25 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-11 18:59:25 +0100
commit93f87c10783e3d76f1dec667779aedffcae33a39 (patch)
tree3b598c49b35b5302a213454debc915cefab506f6
parent1c20e06da5a9817c15c80ca5a25cfacf8eeb0485 (diff)
test(hooks): fix not wrapped in act error in Jest test
-rw-r--r--src/utils/hooks/use-redirection/use-redirection.test.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/utils/hooks/use-redirection/use-redirection.test.ts b/src/utils/hooks/use-redirection/use-redirection.test.ts
index c14ac4c..0dae949 100644
--- a/src/utils/hooks/use-redirection/use-redirection.test.ts
+++ b/src/utils/hooks/use-redirection/use-redirection.test.ts
@@ -1,5 +1,5 @@
import { describe, it } from '@jest/globals';
-import { renderHook } from '@testing-library/react';
+import { act, renderHook } from '@testing-library/react';
import nextRouterMock from 'next-router-mock';
import { MemoryRouterProvider } from 'next-router-mock/MemoryRouterProvider';
import { useRedirection } from './use-redirection';
@@ -12,7 +12,7 @@ describe('useRedirection', () => {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
expect.assertions(2);
- await nextRouterMock.push('/initial-path');
+ await act(async () => nextRouterMock.push('/initial-path'));
expect(nextRouterMock.asPath).toBe(initialPath);
@@ -30,7 +30,7 @@ describe('useRedirection', () => {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
expect.assertions(2);
- await nextRouterMock.push('/initial-path');
+ await act(async () => nextRouterMock.push('/initial-path'));
expect(nextRouterMock.asPath).toBe(initialPath);
@@ -54,7 +54,7 @@ describe('useRedirection', () => {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
expect.assertions(3);
- await nextRouterMock.push('/initial-path');
+ await act(async () => nextRouterMock.push('/initial-path'));
expect(nextRouterMock.asPath).toBe(paths.initial);
@@ -71,7 +71,7 @@ describe('useRedirection', () => {
expect(nextRouterMock.asPath).toBe(paths.initial);
- await nextRouterMock.push(paths.matching);
+ await act(async () => nextRouterMock.push(paths.matching));
rerender();