Skip to content

Error: Module not found: Error: Can't resolve '@angular/animations/browser #519

Closed
@WeiHong2305

Description

@WeiHong2305

Steps to reproduce

  1. I have a plain new Angular v19 project and added Angular Testing Library using this command
ng add @testing-library/angular 
  1. Change src/app/app.component.spec.ts content with code below
import { render, screen } from '@testing-library/angular';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
  it('should render Welcome', async () => {
    await render(AppComponent);
  });
});
  1. I then proceed to run the test using
ng test

Error

Error: Module not found: Error: Can't resolve '@angular/animations/browser

I've tried importing BrowserAnimationsModule but still get the same error

import { render, screen } from '@testing-library/angular';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('AppComponent', () => {
  it('should render Welcome', async () => {
    await render(AppComponent, {
      imports: [BrowserAnimationsModule],
    });
  });
});

Versions

  • Angular: ^19.2.0
  • "@testing-library/angular": "^17.3.6",
  • "@testing-library/dom": "^10.0.0",
  • "@testing-library/jest-dom": "^6.4.8",
  • "@testing-library/user-event": "^14.5.2",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions