Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda