Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 8 and jest - File not found: jest-preset-angular/InlineHtmlStripStylesTransformer.js

Tags:

angular

jestjs

I just created angular application using the cli (v8 - last version from today). nothing special I done so far. (ng new ng-app).

I use jest-schematic to add jest to my angular project.

cd ng-app
ng add @briebug/jest-schematic

The problem is I get an error when I run the test using: npm run test:

> jest

 FAIL  src/app/app.component.spec.ts
  ● Test suite failed to run

    File not found: jest-preset-angular/InlineHtmlStripStylesTransformer.js (resolved as: C:\ng-app\jest-preset-angular\InlineHtmlStripStylesTransformer.js)

What is missing here? How do I fix that?

like image 549
Jon Sud Avatar asked Dec 17 '22 15:12

Jon Sud


1 Answers

In the jest-preset-angular documentation, the corrent configuration is this: jest-preset-angular/build/InlineFilesTransformer.

So change in your package.json the lines from:

   "astTransformers": [
      "jest-preset-angular/InlineHtmlStripStylesTransformer.js"
   ]

to

"astTransformers": [
   "jest-preset-angular/build/InlineFilesTransformer",
   "jest-preset-angular/build/StripStylesTransformer"
]
like image 175
Shlomi Levi Avatar answered Mar 30 '23 00:03

Shlomi Levi