Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda