Skip to content

Commit 20c5f5e

Browse files
Run all tests in React strict mode
1 parent fd6b86a commit 20c5f5e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/setupTests.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { TextDecoder, TextEncoder } from 'node:util';
22
import '@testing-library/jest-dom';
3+
import { configure } from '@testing-library/react';
34
import { outdent } from 'outdent';
45

6+
configure({ reactStrictMode: true });
7+
58
/**
69
* Polyfill TextEncoder/TextDecoder for ReactDOM
710
*
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, type RenderOptions as ClientOptions } from '@testing-library/react';
2-
import { act, type JSX } from 'react';
2+
import { act, StrictMode, type JSX } from 'react';
33
import { renderToString, type ServerOptions } from 'react-dom/server';
44

55
type RenderOptions =
@@ -18,7 +18,7 @@ export async function renderServer(element: JSX.Element, options: RenderOptions
1818
document.body.appendChild(container);
1919

2020
// Render using React DOM
21-
container.innerHTML = renderToString(element, serverOptions);
21+
container.innerHTML = renderToString(<StrictMode>{element}</StrictMode>, serverOptions);
2222

2323
// Find rendered modules
2424
const modules = Array.from(container.querySelectorAll<HTMLElement>(selector));

0 commit comments

Comments
 (0)