New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use attachTo in failing tests with jsdom v21.1 #1952
Conversation
✅ Deploy Preview for vue-test-utils-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
`attachTo` can be removed when jsdom/jsdom#3502 is fixed With jsdom v21.1, `getComputedStyle` is cached and not updated for elements not in the DOM so some our tests fail (because the elements are checked a first time)
5aef13b
to
b1fb6a6
Compare
// TODO: attachTo can be removed when https://github.com/jsdom/jsdom/issues/3502 is fixed | ||
// with jsdom v21.1, getComputedStyle is cached and not updated for elements not in the DOM | ||
// so the test fails (because the element is checked a first time) | ||
const wrapper = mount(Comp, { attachTo: document.body }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I almost wonder if attachTo: document.body should be the default behavior. I wonder if that'd be a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should, I don't know what are the downsides (most testing libs in other ecosystems do attach components right?). As you have more context, do you know why this is not the case in VTU?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine either way, but any reason we need to update to this version of jsdom asap? Should we just wait for the release w/ the patch?
@lmiller1990 We don't have to, I'm fine either way 😉 It's just that:
|
That's fair - happy to move forward with this. Once we merge up all the deps PRs, we can do another release - good to have the latest code in the wild, even if it's just dev dependencies updates that don't make a difference - good to keep a fast release cadence. |
attachTo
can be removed when jsdom/jsdom#3502 is fixedWith jsdom v21.1,
getComputedStyle
is cached and not updated for elements not in the DOMso some our tests fail (because the elements are checked a first time)
We'll probably see issues in Vue projects using VTU and jsdom as well, and we can point to this PR if that happens