briebug / jest-schematic

Angular schematic for adding Jest and the required files to an Angular CLI project
MIT License
322 stars 38 forks source link

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

Closed thogrego closed 1 year ago

thogrego commented 2 years ago

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):

Additional context

Waterstraal commented 2 years ago

I have this exact same issue, using angular 14.2.1

Have you been able to work around this?

Waterstraal commented 2 years ago

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 commented 2 years ago

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

image

Waterstraal commented 2 years ago

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

DasOhmoff commented 2 years ago

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?

schuchard commented 2 years ago

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