I've been facing issues with my tests failing after a recent npm install.
I've tried adjusting versions up and down, but haven't had any success.
Interestingly, the $store isn't directly used in any of the components or tests.
Despite trying various fixes from similar problems, like extending types with a shim, nothing seems to be working.
Packages
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99efecfcd9abb7afb7a8ad">[email protected]</a>
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="741a010c0034465a45415a4c">[email protected]</a>
"@nuxtjs/composition-api": "^0.29.3",
...
"jest-serializer-vue": "^2.0.2",
"@types/jest": "^26.0.8",
"babel-jest": "^26.6.3",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"vue-jest": "^3.0.4",
Errors
All failures are showing the same error.
FAIL pages/__tests__/registrationFormP1.spec.ts
● Test suite failed to run
node_modules/vuex-composition-helpers/src/util.ts:104:9 - error TS2339: Property '$store' does not exist on type 'ComponentInternalInstance | CombinedVueInstance<Vue, object, object, object, Record<never, any>>'.
104 const {$store} = 'proxy' in vm ? vm.proxy : vm;
...
Test Suites: 7 failed, 9 passed, 16 total
Tests: 61 passed, 61 total
jest.setup.ts
import Vue from 'vue';
import Vuex from 'vuex';
import * as CompositionApi from '@nuxtjs/composition-api/module';
import yapilyStyleguide from '@yapily/styleguide';
Vue.use(yapilyStyleguide);
Vue.use(Vuex);
Vue.use(CompositionApi);
Vue.prototype.$permission = () => jest.fn();
jest.config.ts
module.exports = {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js',
},
moduleFileExtensions: ['ts', 'js', 'vue', 'json', 'jsx', 'json'],
transform: {
'^.+\\.(ts|tsx)?$': 'ts-jest',
'^.+\\.(js|jsx)$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest',
'^.+\\.ts?$': 'ts-jest',
},
testMatch: ['<rootDir>/**/*.spec.js', '<rootDir>/**/*.spec.ts'],
collectCoverageFrom: ['<rootDir>/components/**/*.vue', '<rootDir>/pages/**/*.vue', '**/*/*.ts'],
coveragePathIgnorePatterns: ['/node_modules/', '/types/', '/proto/', '/.nuxt/'],
setupFilesAfterEnv: ['./jest.setup.ts'],
snapshotSerializers: ['jest-serializer-vue'],
transformIgnorePatterns: ['<rootDir>/node_modules/(?!vuex-composition-helpers)'],
};