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. 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