question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing all components

See original GitHub issue

In #241, we replaced enzyme by react-testing-library (RTL).

Only a few components were being tested, so we decided to open it for contributions. Whether you’re a beginner (with react, open source or tests) or an experienced developer who want to learn RTL by contributing to this project, this is for you. 😄

Test cases

1️⃣ html attrs: test if a component renders html props (like id, aria-label etc.) - example 2️⃣ styled: test if styles match (for every prop that changes styles) - example 3️⃣ prop: test the behavior of every custom prop - example 4️⃣ lifecycle: test the behavior of lifecycles - example1, example2 5️⃣ events: test the behavior of events - example 6️⃣ others: more tests if the component needs

Components with only 1️⃣2️⃣ are easier.

Instructions

  1. Choose the component you want to test. Please, do one per PR. Components with sub components (e.g. Group and GroupItem) go in a single PR.
  2. Comment on this issue (a member will edit this post with your info).
  3. Take a look at Contributing with code.
  4. Create a __tests__ folder and a ${ComponentName}-test.tsx file inside (you can take a look at other components that are already tested).
  5. Implement the tests while running yarn test --watch.
  6. Commit, push and open the PR. 🎉

Components

Component Status Developer Test cases
Avatar @diegohaz 1️⃣2️⃣
Backdrop @diegohaz 1️⃣2️⃣3️⃣
Block @diegohaz 1️⃣2️⃣
Blockquote @codyaverett 1️⃣2️⃣
Box @ReutSher1 1️⃣2️⃣3️⃣
Button @lluia 1️⃣2️⃣
Card* @lluia 1️⃣2️⃣3️⃣
Code @lluia 1️⃣2️⃣3️⃣
Divider @lluia 1️⃣2️⃣3️⃣
Field @lluia 1️⃣2️⃣
Flex @lluia 1️⃣2️⃣3️⃣
Grid* @lluia 1️⃣2️⃣3️⃣
Group* @lluia 1️⃣2️⃣3️⃣
Heading @lluia 1️⃣2️⃣
Hidden* 🚧 @diegohaz 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣
Image @lluia 1️⃣2️⃣
Inline @lluia 1️⃣2️⃣
InlineBlock @lluia 1️⃣2️⃣
InlineFlex @lluia 1️⃣2️⃣3️⃣
Label 🚧 @rafael-vitor 1️⃣2️⃣
Link 🚧 @rafael-vitor 1️⃣2️⃣
List 🚧 @rafael-vitor 1️⃣2️⃣
Navigation 🚧 @rafael-vitor 1️⃣2️⃣
Overlay* @amogower 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣
Paragraph @lluia 1️⃣2️⃣
Popover* @amogower 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣
Portal @amogower 1️⃣2️⃣4️⃣6️⃣
Sidebar* @amogower 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣
Step* 🚧 @diegohaz 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣
Table* @amogower 1️⃣2️⃣
Tabs* @amogower 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣
Toolbar* @amogower 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣
Tooltip* 🚧 @amogower 1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣

* Contains sub components

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
diegohazcommented, Oct 19, 2018

@gustavo-depaula I don’t think 1️⃣ is testing implementation details.

The user of this library will expect the output element to render all HTML attributes they passed in. This is pretty much testing input/output. I think, though, there should be more effective ways to test that (like, it’s not covering all possible html attributes), but it’s okay for now.

Regarding 2️⃣, it’s useful because we’ll easily see style changes, which are often breaking changes.

1reaction
matheus1lvacommented, Nov 22, 2018

@amogower go for it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Component Testing? Techniques, Example Test Cases
Component testing is defined as a software testing type, in which the testing is performed on each individual component separately without ...
Read more >
What is Component Testing Or Module Testing (Learn With ...
The test cases for component testing are derived from work products, for instance, software design or the data model. Each component is tested ......
Read more >
Component Testing Tutorial: A Comprehensive Guide With ...
Component testing is a subset of software testing that involves validating every component of software applications independently without merging them.
Read more >
What is Component Testing in Software Testing
Basically, a component level testing is primarily driven by four inputs: Project Test Plans, System Requirements, Component Specifications, and ...
Read more >
How to Test Electronic Components | Onlinecomponents.com
This tests if electricity can flow through the component. ... for a tester that can be used on virtually all non power components...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found