Vue · Senior · Question 46 of 75

How do you test a composable that uses lifecycle hooks or inject?

Explanation

Composables that only use reactivity can be called directly. Those needing an instance require a component context; provide values can be passed via global.provide in Vue Test Utils.

Further reading

Problem with a question

Vue · Senior · question 46

Test yourself

Take the Vue · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz