Lazy user event setup call #1052
-
|
To avoid calling const customRender = (ui, options) => ({
get user() {
return userEvent.setup()
},
render: reactTestingLibrary.render(ui, options)
})
module.exports = {
...reactTestingLibrary,
render: customRender
}Usage: // userEvent.setup() invoked
const { user } = render(<.../>)// userEvent.setup() NOT invoked
render(<.../>) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You could add But if it's for avoiding an unnecessary invocation, it's probably not worth the extra choice for the test author. |
Beta Was this translation helpful? Give feedback.
You could add
useron a different function. E.g. in our own tests we have arenderfunction withoutuserand asetupfunction that addsuser.But if it's for avoiding an unnecessary invocation, it's probably not worth the extra choice for the test author.