Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: testing-library/react-testing-library
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v15.0.5
Choose a base ref
...
head repository: testing-library/react-testing-library
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b6e59f7d58c69f617cc9854d8c3e6f86c2dfb0e9
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on May 1, 2024

  1. fix: export new act when available (#1319)

    MatanBobi authored May 1, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b6e59f7 View commit details
Showing with 15 additions and 6 deletions.
  1. +8 −1 package.json
  2. +7 −5 types/index.d.ts
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -51,20 +51,27 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.6",
"@types/react": "^18.3.1",
"chalk": "^4.1.2",
"dotenv-cli": "^4.0.0",
"jest-diff": "^29.7.0",
"kcd-scripts": "^13.0.0",
"npm-run-all": "^4.1.5",
"react": "^18.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.0",
"rimraf": "^3.0.2",
"typescript": "^4.1.2"
},
"peerDependencies": {
"@types/react": "^18.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"eslintConfig": {
"extends": "./node_modules/kcd-scripts/eslint.js",
"parserOptions": {
12 changes: 7 additions & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@ import {
prettyFormat,
Config as ConfigDTL,
} from '@testing-library/dom'
import {act as reactAct} from 'react-dom/test-utils'
import {act as reactDeprecatedAct} from 'react-dom/test-utils'
//@ts-ignore
import {act as reactAct} from 'react'

export * from '@testing-library/dom'

@@ -245,10 +247,10 @@ export function renderHook<
export function cleanup(): void

/**
* Simply calls ReactDOMTestUtils.act(cb)
* Simply calls React.act(cb)
* If that's not available (older version of react) then it
* simply calls the given callback immediately
* simply calls the deprecated version which is ReactTestUtils.act(cb)
*/
export const act: typeof reactAct extends undefined
? (callback: () => void) => void
export const act: typeof reactAct extends never
? typeof reactDeprecatedAct
: typeof reactAct