搜索插件、代码仓与 APP 分类

插件详情v3.0.4

over_react_test

用于测试 OverReact 组件的库

Web
近 30 天下载
9700
喜欢数
1
Pub 分数
85

安装插件

flutter pub add over_react_test

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个专为 OverReact 组件设计的测试库,使开发者能够为 Flutter 中类似 React 的 UI 组件编写可靠单元测试和集成测试。它提供了渲染组件、模拟用户交互和验证输出的工具,确保组件行为符合预期。由 Workiva 开发,该库与 Flutter 测试生态系统无缝集成,并针对 Web 平台进行了优化。该库简化了 OverReact 应用中复杂组件层级和状态管理的测试。

适合场景

  • 测试 OverReact 组件渲染
  • 模拟用户交互,如单击和输入
  • 验证组件状态更改
  • 验证 Web 应用中的 DOM 输出
  • 编写用户界面逻辑的单元测试和集成测试

主要特点

  • 组件渲染工具
  • 事件模拟助手
  • DOM 断言工具
  • Web 平台优化
  • 与 Flutter 测试框架无缝集成

适合对象

  • 使用 OverReact 的 Flutter 开发人员
  • 构建复杂网络用户界面的团队
  • 测试驱动开发工作流程
  • 专注于组件可靠性的前端团队

使用建议

  • 仅限Web平台
  • 需要 OverReact 依赖
  • 可能需要额外的设置来处理复杂状态
  • 最适合已使用 OverReact 的项目

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

OverReact Test

Pub Build Status Documentation

A library for testing OverReact components.

Using it in your project

  1. Import it into your test files:

    import 'package:over_react_test/over_react_test.dart';
    
  2. Run your tests:

    $ dart run test test/your_test_file.dart
    

Naming Conventions

Variables and Types
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);
});
Test IDs

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.goToSelectedButton
    • sox.AbstractDataLayoutGroup.headerBlock.title
  • CONSIDER 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:

    • target all of the Bar component's menu items using foo.Bar.menuItem
    • target the 4th item using foo.Bar.menuItem.3
    • target the item corresponding to an item with id baz123 using foo.Bar.menuItem.baz123

    This won't always be needed, but it comes in handy in certain cases.

Documentation

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.

Contributing

Yes please! (Please read our contributor guidelines first)

Versioning

The over_react_test library adheres to Semantic Versioning:

  • Any API changes that are not backwards compatible will bump the major version (and reset the minor / patch).
  • Any new functionality that is added in a backwards-compatible manner will bump the minor version (and reset the patch).
  • Any backwards-compatible bug fixes that are added will bump the patch version.

所属分类

依赖

依赖清单 6 项

源码仓库

使用此插件的项目

暂无相关数据。