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

Vue3でprovide/injectを使用しているときのVue Test Utilsでのテストの書き方

Posted at

結論

  • Vue Test Utils 2 ではglobalオプションを使ってprovideするよ

v2 の provide/inject に関する変更

変更点

  • provideオプション → 廃止
  • globalオプション → 追加

v1ではマウンティングオプションのprovideを使用していた。
しかし、v2ではprovideオプションがなくなり、代わりにglobalオプションが用意された。

新しいprovide方法

Before

const wrapper = mount(Component, {
  provide: {
    Theme: 'dark'
  }
})

After

const wrapper = mount(Component, {
  global: {
    provide: {
      Theme: 'dark'
    }
  }
})

詳しいことは ↓ を参照

1
1
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
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?