Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
Broma: no se puede importar la imagen cuando se usa simulacro

Estoy tratando de importar una imagen JPEG en ContactListItem.tsx .

 import React from "react"; import { render, screen, RenderResult } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import ContactListItem from "./index"; import Avatar from "src/assets/icons/avatar_1.jpeg"; describe("Testing ContactListItem component", () => {...});

tengo un error

 Jest encountered an unexpected token Jest failed to parse a file. This happens eg when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax. Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration. By default "node_modules" folder is ignored by transformers.

ingrese la descripción de la imagen aquí

Pero ya he creado fileMock para transformar en jest.config.ts

 export default { roots: ["<rootDir>/src"], moduleFileExtensions: ["ts", "tsx", "js", "json", "node"], moduleDirectories: ["node_modules", "src"], moduleNameMapper: { "src/(.*)": "<rootDir>/src/$1", "^.+\\.(png|jpg|jpeg|gif|webp|ico|bmp|svg)$/i": "<rootDir>/src/tests/__mocks__/fileMock.js", "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy", }, testEnvironment: "jsdom", transform: { "^.+\\.tsx?$": "ts-jest", }, transformIgnorePatterns: ["<rootDir>/node_modules/"], };

archivo.simulacro.js

 module.exports = `test-file-stub`;

La jerarquía de mi proyecto:

 -public -src -components -ContactListItem -index.tsx -ContactListItem.test.tsx -tests -__mocks__ -file.mock.js -jest.config.ts
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!