So I have come across this issue making a unit test for an Angular 4 application
What happens is that it keeps giving the error stated here in the question title.
I tried to google it, tried to import a whole bunch of different modules and finally found that a close answer to what this "Platform" is might be the browserModule from @angular/browser
Platform.
So in my unit testing, I tried to import it and declare it but it did not help.
Can anyone please help with this as I'm not even sure what this "Platform" is?
Question: what is exactly this "Platform" in the error and how to fix it?
Thanks.
I have attached my code as below:
import { ComponentFixture, TestBed, async} from "@angular/core/testing";
import { DebugElement, CUSTOM_ELEMENTS_SCHEMA, PlatformRef} from
"@angular/core";
import { TeamCreationAssignmentComponent } from "./team-creation-assignment.component";
import { OdmService } from "../../services/odm/odm.service";
import { UserNotificationService } from "../../services/user/user-notification.service";
import { MatSnackBar } from "@angular/material";
import { OVERLAY_PROVIDERS, ScrollStrategyOptions, ScrollDispatcher} from "@angular/cdk/overlay";
describe('Team creation assignment component', () => {
let comp: TeamCreationAssignmentComponent;
let fixture: ComponentFixture<TeamCreationAssignmentComponent>;
let odmServiceSub = {};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [TeamCreationAssignmentComponent],
//imports: [BrowserModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{provide: OdmService, useValue: odmServiceSub},
UserNotificationService,
MatSnackBar,
OVERLAY_PROVIDERS,
ScrollStrategyOptions,
ScrollDispatcher,
],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TeamCreationAssignmentComponent);
comp = fixture.componentInstance;
});
it('should have defined component', () => {
expect(comp).toBeDefined();
})
});