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

477
Vistas
Using Jest moduleNameMapper without typescript?

i got the current jest config setup as the following:

module.exports = {
  testEnvironment: 'jsdom',
  transform: {
    '^.+\\.vue$': '@vue/vue3-jest',
    '^.+\\js$': 'babel-jest'
  },
  testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(js)$',
  moduleFileExtensions: ['vue', 'js'],
  transformIgnorePatterns: ['/node_modules/(?!@ionic/vue|@ionic/vue-router|@ionic/core|@stencil/core|ionicons)']
}

However this cause an issue when adding a simple vue test:

import { mount } from '@vue/test-utils'
import HomePage from '@/views/HomePage.vue'

describe('HomePage.vue', () => {
  it('renders home vue', () => {
    const wrapper = mount(HomePage)
    expect(wrapper.text()).toMatch('Ready to create an app?')
  })
})

The @ symbol isn't resolved as wanted:

  ● Test suite failed to run

    Cannot find module '@/views/HomePage.vue' from 'tests/unit/example.spec.js'

      1 | import { mount } from '@vue/test-utils'
    > 2 | import HomePage from '@/views/HomePage.vue'
        | ^
      3 |
      4 | describe('HomePage.vue', () => {
      5 |   it('renders home vue', () => {

      at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
      at Object.<anonymous> (tests/unit/example.spec.js:2:1)

However, adding

  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
  },

within the jest.config.js file give me this error:

  ● Test suite failed to run

    Cannot find module 'ts-jest/dist/config/config-set'

Installing ts-jest & typescript would work, but is there any way to fix this issue without having to deal with typescript?

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