Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Vue/Jest unit testing Cannot read property 'shallowMount' of undefined

I have been following the Vue school guides on implementing Jest with Vue in order to start writing some unit tests.

So far I've installed jest, jest-serializer-vue, vue-template-compiler.

module.exports = {
    verbose: true,
    roots: [
        "<rootDir>/src/",
        "<rootDir>/src/specs/"
    ],
    moduleFileExtensions: ['js', 'vue'],
    moduleNameMapper: {
        '^@/(.*)$': '<rootDir>/src/$1',
    },
    transform: {
        "^.+\\.js$": "babel-jest",
        "^.+\\.vue$": "vue-jest",
    },
    snapshotSerializers: [
        "<rootDir>/node_modules/jest-serializer-vue"
    ]
}

When writing my first test it is building successfully.

import TestComponent from '../src/components/test';

test('mount a vue component', () => {
    console.log(TestComponent);
});

But when I try mounting Vue component it starts failing with the following error:

 FAIL  src/specs/test.spec.js
  ● Test suite failed to run

    TypeError: Cannot read property 'shallowMount' of undefined

The actual test file looks like this:

import TestComponent from '../src/components/test';

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

test('mount a vue component', () => {
    const wrapper = shallowMount(TestComponent);

    console.log(wrapper);
});

I don't understand why this is happening, and there is no info (at least I could not find some) as why this is failing. Can someone help me?

PS: My project is NOT using vue-cli.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!