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

230
Views
Absolute path regex in jest.config.js

I would like to match absolute paths with regex in my jest.config.js same way as it is done in jsconfig.json.

 // jest.config.js
 {
   ...
   moduleNameMapper: {
     '^\+\/(.*)$': '<rootDir>/src/styles/'
     '^\~\/(.*)$': '<rootDir>/src/'
  },
 }

'^\+\/(.*)$' should match +/theme/theme and find file located in Project/src/styles/theme/theme

'^\~\/(.*)$' should match '~/components/Account' and find file located in Project/src/components/Account

Regex work: https://regex101.com/r/yXpeAu/1, https://regex101.com/r/jH6ajA/1

Unfortunately something is wrong because I got 2 errors during test run.

  • SyntaxError: Invalid regular expression: /^+/(.*)$/: Nothing to repeat
  • Cannot find module './src/components/Account' from 'src/components/Account

This is how jsconfig.json resolve absolute paths:

// jsconfig.json
{
  "baseUrl": ".",
  "paths": {
  "+/*": ["./src/styles/*"],
  "~/*": ["./src/*"],
  }
}
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!