I have got this error in jest with ng2-charts:
● Test suite failed to run
TypeError: import_chart.registerables is not iterable (cannot read property undefined)
1 | import { Injectable } from '@angular/core';
2 | import { ChartOptions } from 'chart.js';
> 3 | import { ThemeService } from 'ng2-charts';
| ^
4 |
5 | type Theme = 'light-theme' | 'dark-theme';
6 |
at Object.<anonymous> (../../node_modules/ng2-charts/fesm2015/ng2-charts.mjs:257:7)
at Object.<anonymous> (../../libs/core/src/lib/utils/theme/ng2-chart.service.ts:3:1)
at Object.<anonymous> (../../libs/core/src/index.ts:6:1)
at Object.<anonymous> (src/app/features/dashboard/dashboard.component.spec.ts:10:1)
at TestScheduler.scheduleTests (../../node_modules/@jest/core/build/TestScheduler.js:333:13)
at runJest (../../node_modules/@jest/core/build/runJest.js:404:19)
at _run10000 (../../node_modules/@jest/core/build/cli/index.js:320:7)
at runCLI (../../node_modules/@jest/core/build/cli/index.js:173:3)
My app uses jest for testing and the configuration file is:
/* eslint-disable */
export default {
displayName: 'core',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
},
coverageDirectory: '../../coverage/libs/core',
transform: {
'^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$|lodash-es)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
I have got the error after putting lodash-es to jest config, and I have to keep the same configs. This error came after my issue with Angular in Nx