Sage-Bionetworks / rocc-app

Registry of Open Community Challenge (ROCC) web client
Apache License 2.0
0 stars 0 forks source link

Migrate Testing from Karma to Jest #387

Open rrchai opened 2 years ago

rrchai commented 2 years ago
# run unit test
npm test
# run unit test with coverage
npm run test:coverage
# run e2e test
npm run test:e2e

Resources:

rrchai commented 2 years ago

errors raised from jest testing and how to solve it:

  1. add import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

    Unexpected synthetic property @transitionMessages found. Please make sure that:
      - Either `BrowserAnimationsModule` or `NoopAnimationsModule` are imported in your application.
      - There is corresponding configuration for the animation named `@transitionMessages` defined in the `animations` field of the `@Component` decorator (see https://angular.io/api/core/Component#animations).
  2. add import { RouterTestingModule } from '@angular/router/testing';

    NullInjectorError: R3InjectorError(DynamicTestModule)[Router -> Router]: 
      NullInjectorError: No provider for Router!
  3. add import { HttpClientModule } from '@angular/common/http';

    NullInjectorError: R3InjectorError(DynamicTestModule)[AuthService -> AuthService -> HttpClient -> HttpHandler -> HttpHandler]: 
      NullInjectorError: No provider for HttpHandler!
  4. It means you are missing corresponding module and you would need to import the module in the *.spec.ts file

    'xxx' is an Angular component, then verify that it is part of this module
    or 
    Export of name 'xxx' not found!