over_react_test
用於測試 OverReact 組件的程式庫
用於測試 OverReact 組件的程式庫
^1.15.0^0.6.1+1^1.8.0^5.0.0^7.0.0^1.21.1^4.1.0^2.1.2>=2.1.3 <4.0.0>=3.0.0 <5.0.0>=3.2.2 <6.0.0^1.8.0以下為英文專案原文快照,最新內容請造訪 GitHub。
Pub Build Status Documentation
A library for testing OverReact components.
Import it into your test files:
import 'package:over_react_test/over_react_test.dart';
Run your tests:
$ dart run test test/your_test_file.dart
| Usage | Actual Type | Suggested Referencing |
|---|---|---|
render and render helper functions |
ReactComponent | Element |
instance |
| Component class | ReactClass |
type |
VDOM Instance (invoked UiProps) |
ReactElement |
-ReactElement or not suffixed |
findDomNode, queryByTestId, etc. |
Element |
node |
| The Dart component | react.Component (backed by ReactComponent) |
dartInstance |
Invoked UiFactory |
UiProps |
builder |
Example:
test('my test' () {
var sampleBuilder = Sample();
var sampleReactElement = sampleBuilder(); // Or var sample = sampleBuilder();
var instance = render(sampleInstance);
SampleComponent sampleDartInstance = getDartComponent(instance);
var sampleNode = findDomNode(instance);
});
When coming up with test ID strings:
DO NOT use spaces; space-delimited strings will be treated as separate test IDs
Just like CSS class names, you can use multiple test IDs together, and use any one of them to target a given component/node.
PREFER following our naming scheme for consistency across projects:
<library>.<Component>[.<subpart>...].<part>
We recommend including a library abbreviation and component name within a test ID so that it's easy to track down where that ID came from.
Namespacing (.<subpart>) can be added however it makes sense.
Finally, test IDs should be descriptive and useful in the context of tests.
Examples:
wsd.DatepickerPrimitive.goToSelectedButtonsox.AbstractDataLayoutGroup.headerBlock.titleCONSIDER adding multiple IDs to serve different purposes
for (var i = 0; i < items.length; i++) {
// ...
..addTestId('foo.Bar.menuItem')
..addTestId('foo.Bar.menuItem.$i')
..addTestId('foo.Bar.menuItem.${items[i].id}')
// ...
}
With the output of above code, you can:
Bar component's menu items using foo.Bar.menuItemfoo.Bar.menuItem.3baz123 using foo.Bar.menuItem.baz123This won't always be needed, but it comes in handy in certain cases.
You would never skip reading the docs for a new language you are asked to learn, so please don't skip over reading our API documentation either.
Yes please! (Please read our contributor guidelines first)
The over_react_test library adheres to Semantic Versioning: