Тестирование amcharts 4 в angular 8, используя шутку - PullRequest
0 голосов
/ 27 января 2020

Попытка протестировать компонент Angular 8 с помощью Jest, на котором есть график, с использованием amcharts. Единственное решение, которое я нашел, это указать c для React (решение React) . Кажется, что при запуске Jest он использует модули узлов, поэтому прежде чем я думаю, что можно реализовать макет для соответствующего импорта.

Любые идеи?

Сообщение об ошибке:

Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

export { System, system } from "./.internal/core/System";
    ^^^^^^

    SyntaxError: Unexpected token 'export'

       8 |   OnChanges,
       9 | } from '@angular/core';
    > 10 | import * as am4core from '@amcharts/amcharts4/core';
         | ^
      11 | import * as am4charts from '@amcharts/amcharts4/charts';
      12 | import am4themes_animated from '@amcharts/amcharts4/themes/animated';
      13 | import { Moment } from 'moment';

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)

...