搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。