react_testing_library 3.1.1 copy "react_testing_library: ^3.1.1" to clipboard
react_testing_library: ^3.1.1 copied to clipboard

Platformweb

A Dart unit testing library for OverReact components that mimics the API of the JS react-testing-library

example/main.dart

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';
}
4
likes
130
points
136k
downloads

Publisher

verified publisherworkiva.com

Weekly Downloads

A Dart unit testing library for OverReact components that mimics the API of the JS react-testing-library

Repository (GitHub)
Contributing

Documentation

Documentation
API reference

License

unknown (license)

Dependencies

collection, color, js, matcher, meta, react, test

More

Packages that depend on react_testing_library