TransWikia.com

Getting typeError: (options.astTransformers || []).map is not a function while running the test suite in Angular

Stack Overflow Asked by soul true on November 28, 2020

I am getting below error while running jest test cases in Angular. All test suites are failing with this error.

Getting typeError: (options.astTransformers || []).map is not a function while running the test suite in Angular

2 Answers

This solution is for Angular 8/9/10

I would recommend doing these steps:

  1. Uninstall jest-preset-angular
  2. Reinstall jest-preset-angular
  3. Clear jest cache
  4. Retry

If the above solution not working, try installing

npm install --dev ts-jest

Answered by San Jaisy on November 28, 2020

Jest configuration for Angular can be tricky.

I recommend you use jest-preset-angular which is a library that you will import into your Angular project that will manage the configuration of Jest for Angular.

This may be related to the update of Jest 27 that deprecated astTransformers as string[].

Configure your Angular project to use Jest 26 with jest-preset-angular and you should be fine

Answered by Yohan Dahmani on November 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP