Unnecessary replication in jest.config.js files? #8881
adam-marshall
started this conversation in
General
Replies: 1 comment
-
just to add to this, I just came across a scenario where I wanted to add something to each generated EDIT: it looks like if you add to the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Previously I added a
moduleNameMapper
value globally by adding it tojest.preset.js
at the top level of the monorepo. This was to replace lodash-es imports with lodash, so it was better to add globally as lodash could be used anywhere.The individual jest.config.js files for each lib do not contain any value for
moduleNameMapper
so it works globally.However recently I had some pain trying to add a new snapshot serializer 'globally'.
My approach might be wrong here, but I added the snapshot serializer to
jest.preset.js
at the top level of the monorepo. This did not work because each jest.config.js file has the same 3 snapshot serializers (no-ng-attributes, ng-snapshot and html-comment), which means they do not use any snapshotSerializers on jest.preset.js, as that array overrides it.If I delete the array on the individual jest.config.js files then my serializer is executed.
This does pose the question - I am no expert, but is there anything in the jest.config.js files which are generated per app and per lib, that could/should be configured for the whole monorepo instead?
Beta Was this translation helpful? Give feedback.
All reactions