Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/dom-testing-library/api-queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ an error if no elements match.

`queryBy*` queries return the first matching node for a query, and return `null`
if no elements match. This is useful for asserting an element that is not
present. This throws an error if more than one match is found (use `queryAllBy` instead).
present. This throws an error if more than one match is found (use `queryAllBy`
instead).

### queryAllBy

Expand Down Expand Up @@ -86,6 +87,17 @@ document.body.innerHTML = exampleHTML
const exampleInput = screen.getByLabelText(/example/i)
```

> **Note**
>
> You need a global DOM environment to use `screen`. If you're using jest, with
> the
> [testEnvironment](https://jestjs.io/docs/en/configuration#testenvironment-string)
> set to `jsdom`, a global DOM environment will be available for you.
>
> If you're loading your test with a `script` tag, make sure it comes after the
> `body`. An example can be seen
> [here](https://github.com/testing-library/dom-testing-library/issues/700#issuecomment-692218886).

### `screen.debug`

For convenience screen also exposes a `debug` method in addition to the queries.
Expand Down
12 changes: 6 additions & 6 deletions docs/react-testing-library/migrate-from-enzyme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ with React Testing Library.

React Testing Library is part of an open-source project named
[Testing Library](https://github.com/testing-library). There are several other
helpful tools and libraries in the Testing Library project which you can use
to write more useful tests. Besides React Testing Library, here are some
other Testing Library's libraries that can help you along the way:
helpful tools and libraries in the Testing Library project which you can use to
write more useful tests. Besides React Testing Library, here are some other
Testing Library's libraries that can help you along the way:

- **[@testing-library/jest-dom](https://github.com/testing-library/jest-dom)**:
jest-dom provides a set of custom jest matchers that you can use to extend
Expand Down Expand Up @@ -49,9 +49,9 @@ development speed and productivity, since every small change requires rewriting
some part of your tests, even if the change you made does not affect the
component's output.

Re-writing your tests in React Testing library is worthwhile, because you're trading
tests that slow you down for tests that give you more confidence and increase
your productivity in the long run.
Re-writing your tests in React Testing library is worthwhile, because you're
trading tests that slow you down for tests that give you more confidence and
increase your productivity in the long run.

## How to migrate from Enzyme to React Testing Library?

Expand Down
3 changes: 2 additions & 1 deletion docs/vue-testing-library/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ See a working example of `update` in the

## `cleanup`

Unmounts Vue trees that were mounted with [render](#rendercomponent-options-callback).
Unmounts Vue trees that were mounted with
[render](#rendercomponent-options-callback).

> If you are using an environment that supports `afterEach` hook (as in Jest),
> there's no need to call `cleanup` manually. Vue Testing Library handles it for
Expand Down