ReferenceError: Vue is not defined while using shallowMount · Issue #479 · vuejs/vue-jest (original) (raw)

I am working on vue project and while doing unit testing using jest, I am getting following error for shallowMount:

ReferenceError: Vue is not defined

    > 1 | import { shallowMount } from '@vue/test-utils';
        | ^
      2 | import About from '@/views/About.vue';
Following are my devDependencies from package.json:
"devDependencies": {
    "@babel/core": "^7.18.5",
    "@babel/eslint-parser": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.4",
    "@vue/cli-plugin-e2e-cypress": "~5.0.4",
    "@vue/cli-plugin-eslint": "~5.0.4",
    "@vue/cli-plugin-pwa": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.4",
    "@vue/cli-plugin-unit-jest": "^5.0.6",
    "@vue/cli-plugin-vuex": "~5.0.4",
    "@vue/cli-service": "^5.0.4",
    "@vue/compiler-dom": "^3.2.37",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-airbnb": "^6.0.0",
    "@vue/test-utils": "^2.0.0",
    "@vue/vue3-jest": "^28.0.0",
    "babel-jest": "^28.1.1",
    "cypress": "^8.3.0",
    "eslint": "^8.17.0",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-vue": "^9.1.0",
    "eslint-plugin-vuejs-accessibility": "^1.1.0",
    "jest": "^28.1.1",
    "jest-environment-jsdom": "^28.1.1",
    "typescript": "~3.9.3",
    "vue-cli-plugin-i18n": "~2.3.1",
    "vue-cli-plugin-tailwind": "~3.0.0",
    "vue3-jest": "^27.0.0-alpha.1",
    "webpack": "^5.73.0"
  },

Following is my unit test code:

import { shallowMount } from '@vue/test-utils';
import About from '@/views/About.vue';

describe('About.vue', () => {
  test('renders inner text', () => {
    // eslint-disable-next-line no-bitwise
    const wrapper = shallowMount(About);

    expect(wrapper.text()).toContain('about');
  });
});

Following is my Component code:

<template>
  <div class='about'>
    <h1>This is an about page</h1>
  </div>
</template>

<script>
export default { name: 'about' };
</script>

Just wonder if I am doing something wrong with unit test or the component code or does the jest and other supporting libraries require version upgrade/downgrade?