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

431
Vistas
Test suite failed to run Jest (very simple test)

I have inherited a codebase that was created using @vue/cli originally there was no unit-test in the project and I am now trying to add it, so far I have created a very simple test and also added jest to the application.

My simple test looks like this,

import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
import ModalRefactored from '../../src/components/modal2/ModalRefactored.vue';

const localVue = createLocalVue();

describe('ModalRefactored', () => {
    let storeMocks, wrapper;

    beforeEach(() => {
        // Create a fresh store and wrapper instance for every test case.
        wrapper = shallowMount(ModalRefactored, {
            localVue
        });
    });

    test('It should render a modal when open', () => {
        
    });

    test('It should not render an overlay when not open', () => {

    });

    test('It should close whn the user clicks the close button', () => {

    });

    test('It should close when the user presses the esc key', () => {

    });
    
});

My jest config looks like this,

    module.exports = {
       preset: '@vue/cli-plugin-unit-jest'
    }

When I run yarn test:unit I get the following,

ests/unit/ModalRefactored.spec.js

● Test suite failed to run

Cannot find module 'core-js/modules/es.error.cause.js' from 'Api.js'

However, Jest was able to find:
    './Api.d.ts'
    './Api.js'
    './Api.js.map'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'jsx', 'json', 'vue'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

However, Jest was able to find:
    '../core/IPPComponent.js'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'jsx', 'json', 'vue'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

  10 |         this.method = "";
  11 |         this.code = 0;
> 12 |         this.statusCode = 0;
     | ^
  13 |         this.httpCode = 0;
  14 |         this.error = {};
  15 |         this.httpText = "";

  at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:259:17)
  at Object.<anonymous> (../js/dist/Api.js:12:1)

I have no idea what the problem is? I would assume that using shallowMount would run the test standalone?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The file core-js/modules/es.error.cause.js is a recent addition to the core-js module. I ran into the exact same problem with a Vue.js project. The core-js version I experienced the error with was 3.16.0.

Updating the core-js version to the current version (3.21.1) fixed the problem.

The weird thing I experienced is, I grepped the package.json files of all modules in my node_modules directory, and couldn't find any core-js dependency with a newer version than 3.16.0. Also, I only got this error when running my test suite on Windows, not when running on Linux.

about 4 years ago · Juan Pablo Isaza Denunciar
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