Skip to content
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

Merged
merged 1 commit into from Jan 31, 2023

Conversation

cexbrayat
Copy link
Member

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)

We'll probably see issues in Vue projects using VTU and jsdom as well, and we can point to this PR if that happens

@netlify
Copy link

netlify bot commented Jan 28, 2023

Deploy Preview for vue-test-utils-docs ready!

Name Link
🔨 Latest commit b1fb6a6
🔍 Latest deploy log https://app.netlify.com/sites/vue-test-utils-docs/deploys/63d4e78284057f0008b16b6f
😎 Deploy Preview https://deploy-preview-1952--vue-test-utils-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@cexbrayat cexbrayat changed the title fix: use attachTo is failing tests with jsdom v21.1 fix: use attachTo in failing tests with jsdom v21.1 Jan 28, 2023
`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)
// 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 })
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

@lmiller1990 lmiller1990 left a 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?

@cexbrayat
Copy link
Member Author

@lmiller1990 We don't have to, I'm fine either way 😉

It's just that:

  • I was happy to have a workaround and to share it with you
  • I'm not even sure jsdom is going to fix it
  • I wanted to have something to point out if someone opens an issue (we had the same issues in our projects of course)
  • It unblocks Renovate

@lmiller1990
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants