From 0838b8d84f51de3a79a934ae59eecbba938bfccd Mon Sep 17 00:00:00 2001 From: Ben Limmer Date: Sun, 1 Aug 2021 13:18:47 -0600 Subject: [PATCH] chore: globally .use(Vuex) when using instantiated store --- src/__tests__/vuex.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/__tests__/vuex.js b/src/__tests__/vuex.js index 4ff17fa..c41008b 100644 --- a/src/__tests__/vuex.js +++ b/src/__tests__/vuex.js @@ -1,5 +1,6 @@ import '@testing-library/jest-dom' import {render, fireEvent} from '@testing-library/vue' +import Vue from 'vue' import Vuex from 'vuex' import VuexTest from './components/Store/VuexTest' @@ -57,6 +58,12 @@ test('can render with vuex with custom store', async () => { }) test('can render with an instantiated Vuex store', async () => { + // Before calling new Vuex.Store in your code, you'll need to `.use` it on the + // global (or local) Vue instance. In frameworks like Jest, the `setupFilesAfterEnv` + // property is a good place to do this. + // https://jestjs.io/docs/configuration#setupfilesafterenv-array + Vue.use(Vuex) + const {getByTestId, getByText} = render(VuexTest, { store: new Vuex.Store({ state: {count: 3},