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

207
Vistas
Tests fail after adding TypeScript to React Project

I'm attempting to add typeScript to a React project that uses javascript. I changed one class and the functionality works the same but several jest tests failed to run and had this error

Cannot find module 'pathtoclass/updatedTSClass' from 'jsClas'.

this is how I import the functional component

import updatedTSClass from '../../../path/path/updatedTSClass';

here is my tsconfig

  "compilerOptions": {
    "jsx": "react",
    "lib": ["es2019", "dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "checkJs": false,
    "target": "esnext",
    "noEmit": true,
    "removeComments": true,
    "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
    "strict": true,
    "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
    "skipLibCheck": true,
    "sourceMap": true
  },
  "include": ["./src/**/*"],
  "exclude": ["./cypress/**/*", "./coverage/**/*", "node_modules"]
}

jest.config.js

module.exports = {
    modulePaths: [
    "<rootDir>"
  ],

  globals: {
    "ts-jest": {
      "tsConfigFile": "tsconfig.json",
      "enableTsDiagnostics": true
    }
  },

  preset: 'ts-jest',
  transform: {
    '^.+\\.(ts|tsx)?$': 'ts-jest',
    "^.+\\.(js|jsx)$": "babel-jest",
  },
}

.babelrc

{
  "presets": ["@babel/preset-react", "@babel/preset-env", "@babel/preset-typescript"],
  "plugins": ["react-hot-loader/babel", "@babel/plugin-proposal-class-properties"]
}
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