Closed
Description
Since a Svelte component is compiled, it's a little bit harder to be flexible with what elements should wrap the component than what it is in e.g. React where you can wrap your component with some custom JSX directly inline in the test.
With this in mind, what do you think about taking some inspiration from react-testing-library
and allowing the user to customize the target
themselves?
- export const render = (Component, options) => {
+ export const render = (Component, { target, ...options }) => {
+ if (!target) {
+ target = document.body.appendChild(document.createElement('div'))
+ }
// ...
}
test('it renders properly in a table', async () => {
const table = document.createElement('table')
document.body.appendChild(table)
const utils = render(MyTableBody, {target: table})
// ...
})
Metadata
Metadata
Assignees
Labels
No labels