mercredi 15 janvier 2020

JEST map multiple folder structures with moduleNameMapper parameter

I have modules in node_modules folder and those dependancies are like below and use it like:

 import { NxDatepickerComponent } from '@xyz/ngx-ndbx/datefield/xyz-ngx-ndbx-datefield';
 import { NX_DATE_FORMATS } from '@xyz/ngx-ndbx/datefield';

Folder structure is \node_modules@xyz\ngx-ndbx\datefield

For this I have moduleNameMapper as having followings for jest configuaration in package.json file:

"moduleNameMapper": {
  "@jkl(.*)": "<rootDir>/src/app/modules/jkl/$1",
  "@shared(.*)": "<rootDir>/src/app/@shared/$1",
  "^@xyz/(.*)$": "<rootDir>/node_modules/@xyz*"
},

With this configuration only the first import is working and not the second one even if it is in the same folder. Anything I'm missing or doing wrong here?

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire