I'm writing unit tests for an Angular component. When I attempted to run it, I received the following error: "Error: Unexpected value 'DecoratorFactory' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation." Is there anything missing or wrong with my code?
import { HttpClient } from '@angular/common/http';
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { AlertController, NavController, ToastController } from '@ionic/angular';
import { GlobalProvider } from 'src/app/services/app/global';
import { AccountProvider } from 'src/app/services/profile/account';
import { phoneValidation } from 'src/helpers/custom-validators';
import { AccountDetailsPage } from "./account-details";
describe("AccountDetailsPage", () => {
let component: AccountDetailsPage;
let fixture: ComponentFixture<AccountDetailsPage>;
let accountProvider: AccountProvider;
let formBuilder: FormBuilder;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AccountDetailsPage],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{ provide: accountProvider, useValue: {} }
],
imports: [
Component,
NavController,
ToastController,
AlertController,
AccountProvider,
GlobalProvider,
FormGroup,
FormBuilder,
Validators,
phoneValidation,
HttpClient
]
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AccountDetailsPage);
component = fixture.componentInstance;
fixture.detectChanges();
});
describe('method1', () => {
it('should ...', () => {
expect(component).toBeTruthy();
});
});
})