Nuxt test utils and provide/inject

Any idea how to test a component that is using provide and inject, without creating a test only wrapper.

This is what I tried, based on the docs https://test-utils.vuejs.org/api/#global-provide

// in symbols
export const SearchContextKey: InjectionKey<SearchContext> =
  Symbol("SearchContext");

// in test
renderSuspended(SearchResultCard, {
    props: {
      article: { ...article, ...articleData },
    },
    global: {
      provide: {
        [SearchContextKey]: {
          type: 'article'
        }
      }
    }
  });
The official testing suite utils for Vue.js 3
Was this page helpful?