Skip to content

FED-3528 React 18 dual support #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7633da6
Upgrade to @testing-library [dom 8, react 12]
aaronlademann-wf Apr 4, 2022
71eb95d
React 18 Support
aaronlademann-wf Apr 4, 2022
52f689b
Update some deps
aaronlademann-wf Oct 22, 2024
2d515e7
new build process
kealjones-wk Oct 22, 2024
222cb47
fix bundle undefined error
kealjones-wk Oct 22, 2024
fc3a54c
Enable legacy root by default to support testing/migration
greglittlefield-wf Dec 18, 2024
f7d0bb8
Use newer react-dart branch
greglittlefield-wf Dec 18, 2024
7cde957
Fix analysis errors, revert unnecessary casts
greglittlefield-wf Dec 18, 2024
adfb293
Rebuild after fixing process.env.NODE_ENV substitution
greglittlefield-wf Dec 19, 2024
203f36e
Format
greglittlefield-wf Jan 29, 2025
14889c8
Filter out ReactDOM.render deprecation logs by default
greglittlefield-wf Jan 30, 2025
37c8dde
Track JS lockfile
greglittlefield-wf Feb 5, 2025
cc30b80
Rebuild JS
greglittlefield-wf Feb 5, 2025
94435ac
Add ESM version of current React-17-compatible RTL bundle
greglittlefield-wf Feb 10, 2025
dd1b2c3
Set up build to conditionally use React 17/18 compatible version of RTL
greglittlefield-wf Feb 10, 2025
3eb8f0c
Build JS assets
greglittlefield-wf Feb 10, 2025
39a11c6
Add example for manual testing
greglittlefield-wf Feb 11, 2025
5af2504
Add React version test setup validation test
greglittlefield-wf Feb 11, 2025
fd02c66
Pull in React 17 version for a test build - to be reverted
greglittlefield-wf Feb 11, 2025
dac2b64
Revert "Pull in React 17 version for a test build - to be reverted"
greglittlefield-wf Feb 11, 2025
931c541
Address initial feedback
sydneyjodon-wk May 6, 2025
3eb6ba5
Update react-dart
sydneyjodon-wk May 6, 2025
59bab6b
Run both React 17 and React 18 tests
sydneyjodon-wk May 6, 2025
7d06dce
Merge branch 'master' into FED-3528-r18-dual-support
sydneyjodon-wk May 6, 2025
25c9472
Fix template path
sydneyjodon-wk May 6, 2025
887fe70
Fix upload path
sydneyjodon-wk May 6, 2025
71aaffe
Merge branch 'master' into FED-3528-r18-dual-support
sydneyjodon-wk May 7, 2025
2cfcd49
Address merge conflicts
sydneyjodon-wk May 7, 2025
343471e
Add test for new RTL issue to verify React 17 does not have it
sydneyjodon-wk May 7, 2025
927332a
Add JS bundle check and update user-event version back to master
sydneyjodon-wk May 7, 2025
9c70cea
Update CI check to use node
sydneyjodon-wk May 7, 2025
2613096
Fix CI check
sydneyjodon-wk May 7, 2025
dd33af2
Remove setup-creds
sydneyjodon-wk May 7, 2025
926e9cf
Re-build JS bundle and add readme
sydneyjodon-wk May 7, 2025
e3e0f22
Revert rtl-17 back to master's umd bundle with a couple changes
sydneyjodon-wk May 7, 2025
828ff59
Remove commented out code and re-build js
sydneyjodon-wk May 7, 2025
8288d6f
Put waitfor test back
sydneyjodon-wk May 8, 2025
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
33 changes: 30 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,46 @@ jobs:
- name: Check formatting
run: dart format . -l 120 --set-exit-if-changed

js-bundle:
name: Build JS bundle
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm install
working-directory: ./js_src

- name: Build JS bundle
run: npm run build
working-directory: ./js_src

- name: Check for untracked API changes
run: git diff --exit-code

test-unit:
runs-on: ubuntu-latest
name: unit tests (${{ matrix.release-mode && 'release' || 'dev' }})
name: unit tests - React ${{ matrix.react }} (${{ matrix.release-mode && 'release' || 'dev' }})
strategy:
fail-fast: false
matrix:
react: [ 17, 18 ]
release-mode: [true, false]
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: 2.19.6

- name: Switch to React 17 Test HTML
if: ${{ matrix.react == 17 }}
run: |
mv test/unit/unit_test_template.html test/unit/unit_test_template-old.html
mv test/unit/unit_test_template-react17.html test/unit/unit_test_template.html

- name: Install dependencies
run: dart pub get
timeout-minutes: 2
Expand All @@ -54,5 +81,5 @@ jobs:
args+=(--release)
fi

dart run build_runner test "${args[@]}" -- -P concurrent-tests
dart run build_runner test "${args[@]}" -- -P non-concurrent-tests
dart run build_runner test "${args[@]}" -- -P concurrent-tests --preset=react${{ matrix.react }}
dart run build_runner test "${args[@]}" -- -P non-concurrent-tests --preset=react${{ matrix.react }}
1 change: 1 addition & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ targets:
build_web_compilers|entrypoint:
# These are globs for the entrypoints you want to compile.
generate_for:
- example/**
- test/**.browser_test.dart
options:
# List any dart2js specific args here, or omit it.
Expand Down
6 changes: 6 additions & 0 deletions dart_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ presets:
include_tags: run-alone
concurrency: 1
file: test/unit/user_event/type_test.dart

react18:
exclude_tags: react-17

react17:
exclude_tags: react-18
13 changes: 13 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

<!DOCTYPE html>
<html lang="en">
<head>
<title>RTL - React 18</title>
<script src="packages/react/js/react.dev.js"></script>
<script src="packages/react_testing_library/js/react-testing-library.js"></script>
</head>
<body>
<script defer src="main.js"></script>
<script defer src="main.dart.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions example/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:react/react.dart' as react;
import 'package:react_testing_library/react_testing_library.dart';
import 'package:react_testing_library/user_event.dart';

main() {
final content = react.button({
'onClick': (_) {
print('clicked');
throw TestException('intentionally thrown during onClick');
},
}, 'Hello World');
final view = render(content, autoTearDown: false);
final button = view.getByRole('button', name: 'Hello World');
try {
UserEvent.click(button);
} catch (e) {
print('Caught exception $e');
}
}

class TestException implements Exception {
final String message;

TestException(this.message);

@override
String toString() => 'TestException: $message';
}
2 changes: 2 additions & 0 deletions example/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
console.log('window.React.version', window.React.version);
console.log('window.rtl', window.rtl);
9 changes: 9 additions & 0 deletions js_src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The underlying JS source for react_testing_library

The generated JS bundle is outputted in `lib/js/react-testing-library.js`.

To update it, run:

```
npm run build
```
Loading