Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
398f09a
[v13] chore: remove deprecated stuff (#1603)
mdjastrzebski May 6, 2024
b797cf4
[v13] chore: remove react 16 & 17 code (#1602)
mdjastrzebski May 7, 2024
b5cfb98
[v13] chore: remove debug shallow (#1601)
mdjastrzebski May 8, 2024
450e750
[v13] chore: increase required React et al. versions
mdjastrzebski Aug 12, 2024
a3e1c5a
Merge branch 'main' into v13
mdjastrzebski Sep 5, 2024
e6d06a7
Merge branch 'main' into v13
mdjastrzebski Sep 12, 2024
c7f9132
Merge branch 'main' into v13
mdjastrzebski Oct 24, 2024
7455b21
feat: automatically extend matchers (#1684)
mdjastrzebski Oct 24, 2024
3abeac3
Merge branch 'main' into v13
mdjastrzebski Oct 25, 2024
383c241
feat(v13): enable concurrent rendering by default (#1692)
mdjastrzebski Oct 25, 2024
e90360b
refactor(v13): use react act if available (#1695)
mdjastrzebski Oct 25, 2024
1e788b6
chore: alpha release script
mdjastrzebski Oct 25, 2024
93eb539
chore: release v13.0.0-alpha.0
mdjastrzebski Oct 25, 2024
7905bb5
Merge branch 'main' into v13
mdjastrzebski Oct 31, 2024
13bc78a
refactor(v13): remove detect host component names (#1697)
mdjastrzebski Nov 4, 2024
a7404dc
Merge branch 'main' into v13
mdjastrzebski Nov 5, 2024
5a10b31
chore: change tsx to ts
mdjastrzebski Nov 5, 2024
83cafe4
refactor(v13): a11y label helpers (#1666)
mdjastrzebski Nov 5, 2024
f2de20c
chore: basic setup (#1659)
mdjastrzebski Nov 5, 2024
3f1d010
chore: release v13.0.0-alpha.1
mdjastrzebski Nov 5, 2024
71b059b
chore: update examples
mdjastrzebski Nov 5, 2024
868a9fc
Merge branch 'main' into v13
mdjastrzebski Nov 6, 2024
048d17d
chore(v13): remove jest preset (#1700)
mdjastrzebski Nov 6, 2024
2670b59
refactor(v13): cleanup existing code (#1701)
mdjastrzebski Nov 7, 2024
b402d14
chore: release v13.0.0-alpha.2
mdjastrzebski Nov 7, 2024
fec4c03
Merge branch 'main' into v13
mdjastrzebski Nov 7, 2024
b956cbc
chore: v13 beta
mdjastrzebski Nov 12, 2024
9ed7549
chore: release v13.0.0-beta.0
mdjastrzebski Nov 12, 2024
83716c2
Merge branch 'main' into v13
mdjastrzebski Nov 27, 2024
4f842f7
chore: fix example apps
mdjastrzebski Nov 27, 2024
1672880
chore: switch to RC
mdjastrzebski Dec 8, 2024
File filter

Filter by extension

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
Next Next commit
[v13] chore: remove react 16 & 17 code (#1602)
* chore: remove React 16 & 17 code

chore: remove more

chore: react version 18.3.1

docs: migration guide

* refactor: finish merge
  • Loading branch information
mdjastrzebski committed Aug 12, 2024
commit b797cf4cc56e7545974220a9eff580632e96ef4d
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"clean": "del build",
"test": "jest",
"test:ci": "jest --maxWorkers=2 --collectCoverage=true --coverage-provider=v8",
"test:react-17": "scripts/test_react_17",
"typecheck": "tsc",
"flow": "flow",
"copy-flowtypes": "cp typings/index.flow.js build",
Expand Down Expand Up @@ -58,9 +57,9 @@
},
"peerDependencies": {
"jest": ">=28.0.0",
"react": ">=16.8.0",
"react-native": ">=0.59",
"react-test-renderer": ">=16.8.0"
"react": ">=18.2.0",
"react-native": ">=0.73",
"react-test-renderer": ">=18.2.0"
},
"peerDependenciesMeta": {
"jest": {
Expand Down
12 changes: 0 additions & 12 deletions scripts/test_react_17

This file was deleted.

5 changes: 1 addition & 4 deletions src/act.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file and the act() implementation is sourced from react-testing-library
// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js
import { act as reactTestRendererAct } from 'react-test-renderer';
import { checkReactVersionAtLeast } from './react-versions';

type ReactAct = typeof reactTestRendererAct;

Expand Down Expand Up @@ -72,9 +71,7 @@ function withGlobalActEnvironment(actImplementation: ReactAct) {
};
}

const act: ReactAct = checkReactVersionAtLeast(18, 0)
? (withGlobalActEnvironment(reactTestRendererAct) as ReactAct)
: reactTestRendererAct;
const act = withGlobalActEnvironment(reactTestRendererAct) as ReactAct;

export default act;
export { setIsReactActEnvironment as setReactActEnvironment, getIsReactActEnvironment };
36 changes: 10 additions & 26 deletions src/helpers/wrap-async.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* istanbul ignore file */

import act, { getIsReactActEnvironment, setReactActEnvironment } from '../act';
import { getIsReactActEnvironment, setReactActEnvironment } from '../act';
import { flushMicroTasks } from '../flush-micro-tasks';
import { checkReactVersionAtLeast } from '../react-versions';

/**
* Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.
Expand All @@ -11,30 +10,15 @@ import { checkReactVersionAtLeast } from '../react-versions';
* @returns Result of the callback
*/
export async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {
if (checkReactVersionAtLeast(18, 0)) {
const previousActEnvironment = getIsReactActEnvironment();
setReactActEnvironment(false);
const previousActEnvironment = getIsReactActEnvironment();
setReactActEnvironment(false);

try {
const result = await callback();
// Flush the microtask queue before restoring the `act` environment
await flushMicroTasks();
return result;
} finally {
setReactActEnvironment(previousActEnvironment);
}
try {
const result = await callback();
// Flush the microtask queue before restoring the `act` environment
await flushMicroTasks();
return result;
} finally {
setReactActEnvironment(previousActEnvironment);
}

if (!checkReactVersionAtLeast(16, 9)) {
return callback();
}

// Wrapping with act for react version 16.9 to 17.x
let result: Result;
await act(async () => {
result = await callback();
});

// Either we have result or `callback` threw error
return result!;
}
6 changes: 6 additions & 0 deletions website/docs/MigrationV13.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Migration to React Native Testing Library version 13 from version 12.x.

# Breaking changes

## Supported React and React Native versions

This version supports only React 19 and corresponding React Native versions. If you use React 18 or 19, please use latest of v12 versions.

[Note: at the moment there is no React Native for React 19, and React 19 is still in beta, so we use React 18.3 for the time being].

## Removed deprecated \*ByAccessibilityState queries

This deprecated query has been removed as is typically too general to give meaningful results. Use one of the following options:
Expand Down
Loading