All Projects → balavishnuvj → rtl-simple-queries

balavishnuvj / rtl-simple-queries

Licence: MIT license
Simple wrapper queries for @testing-library/react

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rtl-simple-queries

Htmltestrunner
A Test Runner in python, for Human Readable HTML Reports
Stars: ✭ 228 (+1040%)
Mutual labels:  testing-tools
Database cleaner
Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing.
Stars: ✭ 2,750 (+13650%)
Mutual labels:  testing-tools
vision-ui
视觉UI分析工具
Stars: ✭ 165 (+725%)
Mutual labels:  testing-tools
Mockito Scala
Mockito for Scala language
Stars: ✭ 231 (+1055%)
Mutual labels:  testing-tools
Kotlin Compile Testing
A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Stars: ✭ 245 (+1125%)
Mutual labels:  testing-tools
Pywinauto
Windows GUI Automation with Python (based on text properties)
Stars: ✭ 3,175 (+15775%)
Mutual labels:  testing-tools
Junit Dataprovider
A TestNG like dataprovider runner for JUnit with many additional features
Stars: ✭ 226 (+1030%)
Mutual labels:  testing-tools
bibop
Utility for testing command-line tools, daemons, and packages
Stars: ✭ 17 (-15%)
Mutual labels:  testing-tools
Diffx
Pretty diffs for scala case classes
Stars: ✭ 250 (+1150%)
Mutual labels:  testing-tools
fluttertest
Custom flutter testing CLI tool for individual test runs and group testing
Stars: ✭ 15 (-25%)
Mutual labels:  testing-tools
Swaks
Swaks - Swiss Army Knife for SMTP
Stars: ✭ 239 (+1095%)
Mutual labels:  testing-tools
Dinghy
Easier cross-compilation for phones and single boards computers
Stars: ✭ 241 (+1105%)
Mutual labels:  testing-tools
babel-plugin-remove-test-ids
🐠 Babel plugin to strip `data-test-id` HTML attributes
Stars: ✭ 40 (+100%)
Mutual labels:  react-testing
Testrocket
Super simple Ruby testing library
Stars: ✭ 229 (+1045%)
Mutual labels:  testing-tools
allure-nunit
Archived - Allure adapter for NUnit framework.
Stars: ✭ 45 (+125%)
Mutual labels:  testing-tools
Goreplay
As your application grows, the effort required to test it also grows exponentially. GoReplay offers you the simple idea of reusing your existing traffic for testing, which makes it incredibly powerful. Our state of art technique allows you to analyze and record your application traffic without affecting it. This eliminates the risks that come with putting a third party component in the critical path.
Stars: ✭ 14,981 (+74805%)
Mutual labels:  testing-tools
Taiko
A node.js library for testing modern web applications
Stars: ✭ 2,964 (+14720%)
Mutual labels:  testing-tools
go-smtp-mock
SMTP mock server written on Golang. Mimic any 📤 SMTP server behavior for your test environment with fake SMTP server.
Stars: ✭ 76 (+280%)
Mutual labels:  testing-tools
phptt
phptt a.k.a php test tools
Stars: ✭ 15 (-25%)
Mutual labels:  testing-tools
kentan
A modular test data generator for TypeScript
Stars: ✭ 38 (+90%)
Mutual labels:  testing-tools

rtl-simple-queries

Simple wrapper queries for @testing-library/react


Build Status Code Coverage version downloads MIT License

All Contributors

PRs Welcome Code of Conduct

The problem

To get an element from while testing with - @testing-library/react, we have 6 variants viz. getBy, getAllBy, queryBy, queryAllBy, findBy, and findAllBy.

We have to remember which one to use when. The name of methods is entirely a familiarity thing. But just by the name of the method it bit difficult to know which one would throw error if an element is not found or which takes into account async updates.

This solution

This library wraps those methods with easier to remember APIs

Table of Contents

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev rtl-simple-queries

Usage

screen can be exported from 'rtl-simple-queries'

Addional parameters from sync query allowEmpty and allowMultiple and for async we only have one option allowMultiple

import {screen} from 'rtl-simple-queries'

screen.fetchByText(/text/, {allowEmpty: true, allowMultiple: false})
screen.fetchByText(/text/, {allowMultiple: false})
screen.fetchByText(/text/)

// async
await screen.fetchByTextAsync(/text/, {allowMultiple: true})

To use queies for scoped container we could do

// test-utils. js
function render(component, options) {
  const utils = rtlRender(component, options)
  const queries = getSimpleQueries(utils)
  return {...utils, ...renderSyncQueries}
}

// use this render instead of importing from @testing-library/react
const {fetchByText} = render(<p>text</p>)

Other Solutions

You can refer to cheatsheet as a quick reference.

Issues

Looking to contribute? Look for the Good First Issue label.

🐛 Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

See Bugs

💡 Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.

See Feature Requests

Contributors

Thanks goes to these people (emoji key):


Balavishnu V J

💻 📖 🚇 ⚠️

Kent C. Dodds

🤔 📖

Paul Coroneos

📖

Adam Ochayon

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].