1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vue-test-utils finding components with find is deprecatedの対処

Last updated at Posted at 2020-05-20

この記事は何?

vue-test-utilsの次のメジャーバージョンでは、Componentを取る目的でのfindの使用がdeprecatedになるそうなので対処方法を書きます。

対処方法

Componentをfindしたい時はfindComponentメソッドを使いましょう。それ以外の用途ではfindのままでOK。

VueTest.spec.js
// 略
expect(wrapper.find('.any-class').exists()).toBe(true) // OK
expect(wrapper.find(AnyComponent).exists()).toBe(true) // OK, but this usage is deprecated

expect(wrapper.findComponent(AnyComponent).exists()).toBe(true) // OK
// 略

参考

https://vue-test-utils.vuejs.org/api/wrapper/find.html
https://vue-test-utils.vuejs.org/ja/api/wrapper/find.html

日本語docではまだdeprecation warningが出ていないんですね。(2020/5中旬時点)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?