Skip to content
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

FED-3273 SPIKE - do not merge: React 18 dual versions #82

Draft
wants to merge 9 commits into
base: r18
Choose a base branch
from
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
14 changes: 14 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

<!DOCTYPE html>
<html lang="en">
<head>
<title>RTL - React 18</title>
<script src="packages/react/react.js"></script>
<script src="packages/react/react_dom.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);
Loading