jest-schematic icon indicating copy to clipboard operation
jest-schematic copied to clipboard

Validation Error: Preset jest-preset-angular not found.

Open thogrego opened this issue 3 years ago • 5 comments

Describe the bug After running the command "ng add @briebug/jest-schematic" inside of my angular app and then running "ng test", I receive an error:

Validation Error:

Preset jest-preset-angular not found.

Configuration Documentation: https://jestjs.io/docs/configuration

To Reproduce

  1. Create a new ng app via CLI
  2. Navigate to new app folder via CLI
  3. execute CLI command "ng add @briebug/jest-schematic"
  4. execute CLI command "ng test"

Expected behavior I expected the 3 default unit tests in my app.component.spec.ts to pass successfully.

Screenshots image

Desktop (please complete the following information):

  • OS: Windows 10
  • Node version: v16.13.0
  • App type: Angular CLI
  • Angular version: 13.3.7

Additional context

thogrego avatar Jun 07 '22 14:06 thogrego

I have this exact same issue, using angular 14.2.1

Have you been able to work around this?

Waterstraal avatar Sep 09 '22 08:09 Waterstraal

To get it working, I did the following:

npm install -D jest jest-preset-angular

in setup-jest.ts: change import 'jest-preset-angular/setup-jest'; to import 'jest-preset-angular';

Waterstraal avatar Sep 09 '22 08:09 Waterstraal

I still see some issues in test-config.helper.ts. Since Angular 14.2 TestBed.configureCompiler returns a void instead of TestBedStatic.

image

Waterstraal avatar Sep 09 '22 08:09 Waterstraal

When I delete test-config.helper.ts, everything still seems to run fine. Is this file still needed for something?

Waterstraal avatar Sep 09 '22 08:09 Waterstraal

I also have this same issue with the test-config.helper.ts file. How can this be fixed? Just deleting the file seems a little risky for me. @schuchard What is the current status of this and how can this be fixed?

DasOhmoff avatar Oct 04 '22 09:10 DasOhmoff

Can you test with latest v5.0.0 and let me know if that helps? test-config.helper.ts has been removed.

schuchard avatar Oct 24 '22 02:10 schuchard