Skip to content

Commit 33e88a0

Browse files
committed
Update container and baseElement references
1 parent 855e670 commit 33e88a0

File tree

1 file changed

+19
-3
lines changed
  • docs/vue-testing-library

1 file changed

+19
-3
lines changed

docs/vue-testing-library/api.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,31 @@ const { getByLabelText, queryAllByTestId } = render(Component)
107107

108108
#### `container`
109109

110-
The containing DOM node of your rendered Vue Component. It's a `div`. This is a
111-
regular DOM node, so you can call `container.querySelector` etc. to inspect the
112-
children.
110+
By default, `Vue Testing Library` will create a `div` and append it to the
111+
`baseElement`. This is where your component will be rendered. If you provide
112+
your own HTMLElement container via this option, it will not be appended to the
113+
`baseElement` automatically.
114+
115+
```js
116+
const table = document.createElement('table')
117+
118+
const { container } = render(TableBody, {
119+
container: document.body.appendChild(table),
120+
})
121+
```
113122

114123
> Tip: To get the root element of your rendered element, use
115124
> `container.firstChild`.
116125
117126
#### `baseElement`
118127

128+
`baseElement` is used as the base element for the queries as well as what is
129+
printed when you use `debug()`.
130+
131+
It matches `container` if not custom `baseElement` is provided. If neither
132+
`baseElement` or `container` options are provided, `baseElement` defaults to
133+
`document.body`.
134+
119135
#### `debug(element)`
120136

121137
This method is a shortcut for `console.log(prettyDOM(element))`.

0 commit comments

Comments
 (0)