Testing React Components Flashcards

1
Q

What is JEST?

A

Is a test runner and test assertion library.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the first principle of unit tests?

A

Never trust a test until you have seen it fail.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When to write tests?

A

When the value of the tests outweigh the test execution time and the complexity it adds up to the code base.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What aspects of the application should my react unit tests cover?

A

The user interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the storybook library do?

A

Render the *.story.js files in a ‘listable’ and ‘searchable’ manner

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the ‘React Testing Library’ guideline?

A

The more your tests resembles the way your software is used the more confidence you’ll get.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How would you test a label element that shows “Username:” following the React Testing Library guidelines and best practices? Why not looking for a label element containing a specific id or other very-specific css selector?

A

getByText(‘username’). Because it will make it hard to refactor/change that component since we’re testing the implementation and not the final result (which is ‘username:’ being render).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly