0

I am trying to generate unit tests from CLI generated app in Angular 16.

Used to do it with ngentest, however if I try that now, getting error:

\src\app> gentest app.component.ts        
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Angular\test\node_modules\@angular\core\fesm2022\core.mjs not supported.
Instead change the require of C:\Angular\coach-test\node_modules\@angular\core\fesm2022\core.mjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (<anonymous>:10:16)
    at requireFromString (C:\Users\olegk\AppData\Roaming\npm\node_modules\ngentest\node_modules\require-from-string\index.js:28:4)
    at run (C:\Users\olegk\AppData\Roaming\npm\node_modules\ngentest\index.js:159:21)
    at Object.<anonymous> (C:\Users\olegk\AppData\Roaming\npm\node_modules\ngentest\index.js:228:3) {
  code: 'ERR_REQUIRE_ESM'
}

Any easy way to fix it? Or use some other way of generating unit tests in ng 16?

Please advise, TIA, Oleg.

Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
user1981152
  • 119
  • 1
  • 1
  • 10
  • I am using VS Code. It looks like ngentest is not updated since 2021. I also noticed that some unit tests were generated in that generated app by CLI. I would like to try doing some TDD in Angular 16. Is IntelliSense extension for VS Code a good candidate for that (or as a unit test generator)? – user1981152 Jun 26 '23 at 02:30

0 Answers0