1
1

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 5 years have passed since last update.

isVisible is deprecated and will be removed in the next major version.

Last updated at Posted at 2020-07-13

はじめに

Jest ^25.5.4を利用してMocalが表示されることをテストしてみました。

  const modal = wrapper.find('modal-stub')
  expect(modal.isVisible()).toBe(true)

その際、テストは通るものの、以下のような警告がコンソールに表示されました。
どうやら、将来的にisVisible()は削除されるとのことです。

[vue-test-utils]: isVisible is deprecated and will be removed in the next major version. Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobevisible. When using with findComponent, access the DOM element with findComponent(Comp).element.

対応

今回は以下のように回避しましたが、別途、jest-domというライブラリを使用するという方法もあるようです。
こちらにQiitaでも記事を書いてくださっている方がいらっしゃいるようです。

  const modal = wrapper.find('modal-stub')
  expect(modal.exists()).toBe(true)

追記

コメントで頂いたように、isVisible()は存在チェックに利用するのは正しい使い方ではないです。
それを理解したうえで使うのもありかもしれませんが、やはりjest-domを利用するのがよさそうです。。

1
1
3

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?