Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ddf9df9
add `renderWithoutAct` helper
phryneas Nov 26, 2024
e8616b3
painful progress
phryneas Nov 26, 2024
5ff5420
make render async to wait for first render
phryneas Nov 27, 2024
c124751
all tests passing
phryneas Nov 27, 2024
20ef3eb
more tweaking
phryneas Nov 27, 2024
b086f98
fix type
phryneas Nov 27, 2024
6fb6fb1
also wrap asyncWrapper
phryneas Nov 27, 2024
8474b54
export `RenderWithoutActAsync` type
phryneas Nov 27, 2024
d926b40
build legacy root in React 16/17
phryneas Nov 28, 2024
1ad050f
disable act with confidence
phryneas Nov 28, 2024
9ef55bb
don't auto-disable act, throw error instead
phryneas Nov 29, 2024
2c5b29e
adjust imports
phryneas Nov 29, 2024
69a4c4b
wait a bunch longer so react doesn't batch
phryneas Nov 29, 2024
c064440
add comment
phryneas Nov 29, 2024
932f938
guard in tests against accidental `IS_REACT_ACT_ENVIRONMENT`
phryneas Nov 29, 2024
451d67a
drain the microtask queue before returning from `peekRender`
phryneas Nov 29, 2024
53d9f45
directly import from `@testing-library/dom` where possible
phryneas Nov 29, 2024
32daf10
move `useWithoutAct` into `disableActEnvironment`, reduce api size
phryneas Dec 2, 2024
084b691
keep `writable` at cleanup
phryneas Dec 2, 2024
563b934
early bailout in `cleanup`
phryneas Dec 2, 2024
0e9d9d7
keep `renderWithoutAct` private
phryneas Dec 2, 2024
94f35e5
`renderToRenderStream` also should be async
phryneas Dec 2, 2024
262ceba
make `rerender` wait for the render and return `Promise<void>`
phryneas Dec 2, 2024
c09b997
update README
phryneas Dec 2, 2024
200d9d2
remove unused type
phryneas Dec 2, 2024
0cf8f41
undo `renderToRenderStream` changes
phryneas Dec 2, 2024
20601bc
add type export back
phryneas Dec 2, 2024
e1cb39d
update type
phryneas Dec 2, 2024
fab8705
guard against sync rerenders
phryneas Dec 2, 2024
04c222d
remove `renderToRenderStream`
phryneas Dec 3, 2024
324ae88
add lint pr job
phryneas Dec 3, 2024
e1eae04
avoid uncaught promise rejection in test
phryneas Dec 3, 2024
7e9ac02
Merge branch 'main' into pr/noActRender
phryneas Dec 3, 2024
7ea9591
run tests with React 19 RC1
phryneas Dec 3, 2024
7ede425
use `use` over the shim when available
phryneas Dec 3, 2024
f3fb67d
Apply suggestions from code review
phryneas Dec 4, 2024
b0d022f
adjust import
phryneas Dec 4, 2024
4d2345b
review suggestions
phryneas Dec 4, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
review suggestions
  • Loading branch information
phryneas committed Dec 4, 2024
commit 4d2345b6c5e725be01d41d1452c089a477c470c6
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ await expect(snapshotStream).toRerender()

## Usage side-by side with `@testing-library/react` or other tools that use `act` or set `IS_REACT_ACT_ENVIRONMENT`

This library should not be used with `act`, and it will throw an error if `IS_REACT_ACT_ENVIRONMENT` is `true`
throw an error if `IS_REACT_ACT_ENVIRONMENT` is `true`.

React Testing Library sets `IS_REACT_ACT_ENVIRONMENT` to `true`
globally, and wraps some helpers like `userEvent.click` in `act` calls.
This library should not be used with `act`, and it will throw an error if
`IS_REACT_ACT_ENVIRONMENT` is `true`.

React Testing Library sets `IS_REACT_ACT_ENVIRONMENT` to `true` globally, and
wraps some helpers like `userEvent.click` in `act` calls.
To use this library side-by-side with React Testing Library, we ship the
`disableActEnvironment` helper to undo these changes temporarily.

It returns a `Disposable` and can be used together with the `using` keyword to
automatically clean up once the scope is left:
It returns a `Disposable` and can be used together with the
[`using` keyword](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management)
to automatically clean up once the scope is left:

```ts
test('my test', () => {
Expand All @@ -290,7 +290,8 @@ test('my test', () => {
```

If you cannot use `using`, you can also manually call the returned `cleanup`
function:
function. We recommend using `finally` to ensure the act environment is cleaned
up if your test fails, otherwise it could leak between tests:

```ts
test('my test', () => {
Expand Down
Loading