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

find is deprecated, findComponent fails #1643

Closed
cyberalien opened this issue Aug 14, 2020 · 8 comments
Closed

find is deprecated, findComponent fails #1643

cyberalien opened this issue Aug 14, 2020 · 8 comments

Comments

@cyberalien
Copy link

Subject of the issue

Function find() was deprecated, but there is no viable alternative.

Steps to reproduce

Replaced find() with findComponent() as per deprecation notice.

Expected behaviour

Renaming function should not change its behavior, tests should continue to run.

Actual behaviour

Tests started to fail with this error: You cannot chain findComponent off a DOM element. It can only be used on Vue Components.

How to continue testing DOM elements created by Vue component after find() is gone?

@afontcu
Copy link
Member

afontcu commented Aug 14, 2020

Hi! find is not deprecated – only searching for a Component using find is 😃

More on that: https://vue-test-utils.vuejs.org/upgrading-to-v1/#find

Hope it helps!

@cyberalien
Copy link
Author

Sorry, my description probably was confusing. I am searching for component, but getting that error regardless:

This is a basic test:

describe('Mounting component', () => {
	test('without wrapper', () => {
		const wrapper = mount(IconifyIcon, {});
		const item = wrapper.find(IconifyIcon);
		expect(item.exists()).toBe(true);
		expect(item.html()).toStrictEqual(
			'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16"></svg>'
		);
	});
});

Function find() shows notice, when replaced with findComponent() throws error.

Component is here: https://github.com/iconify/iconify/blob/master/packages/vue/src/IconifyIcon.ts
Tests are here: https://github.com/iconify/iconify/blob/master/packages/vue/tests/icon.test.js (all fail after replacing find with findComponent, except for first test)

@cyberalien
Copy link
Author

It is a functional component with render() function, if that makes difference.

@nwoltman
Copy link

I believe this was fixed by #1593. A new version of VTU just hasn't been released since that PR was merged.

@afontcu
Copy link
Member

afontcu commented Aug 15, 2020

Yeah, that sounds about right! We'll issue a release in the upcoming days, I'll let you know!

@cyberalien
Copy link
Author

cyberalien commented Aug 15, 2020 via email

@lmiller1990
Copy link
Member

VTU new version about 2 days ago I am not sure if this is fixed there, let me know.

@cyberalien
Copy link
Author

Yes, that fixed it. Thank you!

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

No branches or pull requests

4 participants