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

205
Visualizações
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 à 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