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

486
Views
(moduleNameMapper not applied) Vue jest configuration error: "Could not locate module @/javascript/app.vue mapped as:"

I have a Vue2 Rails application and tried to install Jest which worked. The problem is that I cannot test my components because of this error:

  ● Test suite failed to run

    Configuration error:
    
    Could not locate module @/app.vue mapped as:
    /Users/name/project/project-name/src/app.vue.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^@\/(.*)$/": "/Users/name/project/project-name/src/$1"
      },
      "resolver": null
    }

Which makes sense, because my component is in /Users/name/project/project-name/app/javascript/app.vue and there is no src directory in my project, because it is a Rails app.

But in my package.json I added

"jest": {
    "moduleNameMapper": {
      "^@/(.*)$": "<rootDir>/app/javascript/$1"
    },
    "preset": "@vue/cli-plugin-unit-jest/presets/no-babel"
  }

Which obviously does not work. Putting all of it into a src folder also does not work. I feel like I'm missing some crucial configuration.

Edit: Alright, I went in and changed my moduleNameMapper by hand which is definitely not how this should be done, but I couldn't get it to work otherwise. In node_modules/jest-resolve/build/index.js at line 121 I wrote

this._options.moduleNameMapper[0].moduleName = "/Users/name/project/project-name/app/javascript/$1";

I don't have time to figure out the real issue right now. I will come back when I have the real solution.

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!