question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run test with jest "Cannot find module 'ng2-charts'"

See original GitHub issue

I cannot execute my jest tests with the newest version 3.0.1. I get following error:

    Cannot find module 'ng2-charts' from 'src/app/pages/text.component.ts'

    Require stack:
      src/app/pages/test-chart.component.ts
      src/app/pages/test.component.ts
      src/app/pages/test.spec.ts

    >  7 | import { BaseChartDirective } from "ng2-charts";
         | ^

   at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:322:11)
      at Object.<anonymous> (src/app/pages/devices/device-detail/dialog-chart/dialog-chart.component.ts:7:1)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
btvanhoosercommented, Dec 17, 2021

I copied as much as I could configuration-wise from my site, and then used the demo (https://valor-software.com/ng2-charts/#LineChart) for the UI/logic to ensure it wasn’t an issue with that.

Just running the tests via npm run test will show the issue as image

Repo with minimal project: https://github.com/btvanhooser/ng2-charts-issue

2reactions
santam85commented, Dec 17, 2021

Can you share a minimum reproduction project?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest test error with chartjs (ng2-charts) on Angular
Jest shows me a "TypeError: import_chart.registerables is not iterable" error during the test of a component that uses ng2-charts :
Read more >
cannot find module '@angular/core/testing' from ... - You.com
After upgrading from Angular 10 -> Angular 14, I am unable to run tests using Jest, with the common message being. Cannot find...
Read more >
Angular jest test bpmnModeler error - Modeler - Forum - bpmn.io
I am trying to run a jest test(which renders a bpmn diagram) and I am using angular 11. Though i am getting TypeError...
Read more >
ng2-charts | Yarn - Package Manager
ng2 -charts doesn't work with newly created angular 10 project #1268 ; Error: getInternalNameOfClass() called on a non-ES5 class #1264 ; export 'defineInjectable' ......
Read more >
[Solved]-Cannot find module 'chart.js' - appsloveworld
With the way the typings were defined for chartjs, you don't need to import it. It is in the global space, so you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found