Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

433
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda