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

363
Views
jest no puede resolver las importaciones de patrones de subruta de módulos de nodo

construyo un proyecto usando node express y usando https://nodejs.org/api/packages.html#packages_subpath_patterns para evitar "../../../xxx.js"

Agregué esto a package.json y funcionó perfectamente

 "imports": { "#src/*": "./src/*.js" }

Pero el problema cuando traté de ejecutar la prueba de broma me dio este error

 Cannot find module '#src/config/database.js' from 'src/database/connection.js' Require stack: src/database/connection.js test/admin.test.js 1 | import { MongoClient } from "mongodb"; > 2 | import databaseConfig from "#src/config/database.js"; | ^ at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:311:11) at Object.<anonymous> (src/database/connection.js:2:1)

No sé cómo resolver este problema, intenté encontrar una solución en Google y la documentación no puede encontrar un problema similar con este

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Agregue esto en su configuración de Jest (por ejemplo, jest.config.json)

 "moduleNameMapper": { "#src/(.*)": "<rootDir>/src/$1" }

Consulte el atributo moduleNameMapper en los documentos de configuración de Jest.

over 4 years ago · Santiago Trujillo Report
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!